|
import numpy as np |
|
import pandas as pd |
|
import gradio as gr |
|
import pickle |
|
|
|
|
|
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) |
|
|
|
|
|
|
|
def predict_placement(option, degree_p, internship, DSA, java, management, |
|
leadership, communication, sales): |
|
if option == "Fullstack": |
|
new_data = pd.DataFrame( |
|
{ |
|
'degree_p': degree_p, |
|
'internship': internship, |
|
'DSA': DSA, |
|
'java': java, |
|
}, |
|
index=[0]) |
|
prediction = rf_fullstk.predict(new_data) |
|
probability = rf_fullstk.predict_proba(new_data)[0][1] |
|
elif option == "Marketing": |
|
new_data = pd.DataFrame( |
|
{ |
|
'degree_p': degree_p, |
|
'internship': internship, |
|
'management': management, |
|
'leadership': leadership, |
|
}, |
|
index=[0]) |
|
prediction = rf_mkt.predict(new_data) |
|
probability = rf_mkt.predict_proba(new_data)[0][1] |
|
|
|
elif option == "Production Engineer": |
|
new_data = pd.DataFrame( |
|
{ |
|
'degree_p': degree_p, |
|
'internship': internship, |
|
'communication': communication, |
|
'sales': sales, |
|
}, |
|
index=[0]) |
|
prediction = rf_prodengg.predict(new_data) |
|
probability = rf_prodengg.predict_proba(new_data)[0][1] |
|
|
|
else: |
|
return "Invalid option" |
|
|
|
if prediction == 1: |
|
return f"{probability:.2f}" |
|
else: |
|
return f"{probability:.2f}" |
|
|
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict_placement, |
|
inputs=[ |
|
gr.inputs.Dropdown(["Fullstack", "Marketing", "Production Engineer"], |
|
label="Select Option"), |
|
gr.inputs.Number(label="Degree Percentage"), |
|
gr.inputs.Number(label="Internship"), |
|
gr.inputs.Checkbox(label="DSA"), |
|
gr.inputs.Checkbox(label="Java"), |
|
gr.inputs.Checkbox(label="Management"), |
|
gr.inputs.Checkbox(label="Leadership"), |
|
gr.inputs.Checkbox(label="Communication"), |
|
gr.inputs.Checkbox(label="Sales"), |
|
], |
|
outputs=gr.outputs.Textbox(label="Placement Prediction"), |
|
title="Placement Prediction", |
|
description= |
|
"Predict the chances of placement for different job roles using machine learning models.", |
|
) |
|
|
|
|
|
iface.launch(share=True) |
|
|