File size: 2,968 Bytes
154b7a1
e6b2bd9
 
4892bb0
e6b2bd9
4892bb0
 
 
 
 
 
 
e6b2bd9
4892bb0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6b2bd9
4892bb0
 
e6b2bd9
4892bb0
 
 
 
 
 
e6b2bd9
4892bb0
e6b2bd9
4892bb0
 
e6b2bd9
 
4892bb0
 
e6b2bd9
4892bb0
 
 
 
e6b2bd9
 
4892bb0
 
 
e6b2bd9
dab724c
4892bb0
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import gradio as gr
import numpy as np
import pandas as pd
import pickle

# Load trained models
with open('rf_hacathon_fullstk.pkl', 'rb') as f1:
    rf_fullstk = pickle.load(f1)
with open('rf_hacathon_prodengg.pkl', 'rb') as f2:
    rf_prodengg = pickle.load(f2)
with open('rf_hacathon_mkt.pkl', 'rb') as f3:
    rf_mkt = pickle.load(f3)

# Define prediction function
def predict_placed(degree_p, internship, DSA, java, management, leadership, communication, sales, model_name):
    if model_name == 'Full Stack':
        new_data = pd.DataFrame({
            'degree_p': degree_p,
            'internship': internship,
            'DSA': DSA,
            'java': java,
            'management': 0,
            'leadership': 0,
            'communication': 0,
            'sales': 0
        }, index=[0])
        model = rf_fullstk
    elif model_name == 'Product Engineering':
        new_data = pd.DataFrame({
            'degree_p': degree_p,
            'internship': internship,
            'DSA': 0,
            'java': 0,
            'management': management,
            'leadership': leadership,
            'communication': 0,
            'sales': 0
        }, index=[0])
        model = rf_prodengg
    elif model_name == 'Marketing':
        new_data = pd.DataFrame({
            'degree_p': degree_p,
            'internship': internship,
            'DSA': 0,
            'java': 0,
            'management': 0,
            'leadership': 0,
            'communication': communication,
            'sales': sales
        }, index=[0])
        model = rf_mkt

    prediction = model.predict(new_data)
    probability = model.predict_proba(new_data)[0][1]

    if prediction == 1:
        result = 'Placed'
        probability_message = f"You will be placed with a probability of {probability:.2f}"
    else:
        result = 'Not Placed'
        probability_message = ""

    return result, probability_message

# Create Gradio interface
inputs = [
    gr.inputs.Number(label='Degree Percentage', min_value=0, max_value=100),
    gr.inputs.Radio(label='Internship', choices=[0, 1]),
    gr.inputs.Radio(label='Data Structures & Algorithms', choices=[0, 1]),
    gr.inputs.Radio(label='Java', choices=[0, 1]),
    gr.inputs.Radio(label='Management Skills', choices=[0, 1]),
    gr.inputs.Radio(label='Leadership Skills', choices=[0, 1]),
    gr.inputs.Radio(label='Communication Skills', choices=[0, 1]),
    gr.inputs.Radio(label='Sales Skills', choices=[0, 1]),
    gr.inputs.Dropdown(label='Model Name', choices=['Full Stack', 'Product Engineering', 'Marketing'])
]

outputs = [
    gr.outputs.Textbox(label='Placement Result'),
    gr.outputs.Textbox(label='Placement Probability')
]

app = gr.Interface(
    fn=predict_placed,
    inputs=inputs,
    outputs=outputs,
    title='Placement Prediction',
    description='Predict placement outcome based on given inputs',
    allow_flagging=False
)

# Run the app
if __name__ == '__main__':
    app.run()