Spaces:
Runtime error
Runtime error
import gradio as gr | |
import numpy as np | |
import pandas as pd | |
import joblib | |
# Load the trained models | |
rf_fullstk = joblib.load('rf_hacathon_fullstk.pkl') | |
rf_prodengg = joblib.load('rf_hacathon_prodengg.pkl') | |
rf_mkt = joblib.load('rf_hacathon_mkt.pkl') | |
# Define prediction functions for each model | |
def predict_fullstk(degree_p, internship, DSA, java): | |
new_data = pd.DataFrame({ | |
'degree_p': degree_p, | |
'internship': internship, | |
'DSA': DSA, | |
'java': java, | |
}, index=[0]) | |
prediction = rf_fullstk.predict(new_data)[0] | |
probability = rf_fullstk.predict_proba(new_data)[0][1] | |
return 'Placed' if prediction == 1 else 'Not Placed', probability | |
def predict_prodengg(degree_p, internship, management, leadership): | |
new_data = pd.DataFrame({ | |
'degree_p': degree_p, | |
'internship': internship, | |
'management': management, | |
'leadership': leadership, | |
}, index=[0]) | |
prediction = rf_prodengg.predict(new_data)[0] | |
probability = rf_prodengg.predict_proba(new_data)[0][1] | |
return 'Placed' if prediction == 1 else 'Not Placed', probability | |
def predict_mkt(degree_p, internship, communication, sales): | |
new_data = pd.DataFrame({ | |
'degree_p': degree_p, | |
'internship': internship, | |
'communication': communication, | |
'sales': sales, | |
}, index=[0]) | |
prediction = rf_mkt.predict(new_data)[0] | |
probability = rf_mkt.predict_proba(new_data)[0][1] | |
return 'Placed' if prediction == 1 else 'Not Placed', probability | |
# Create input and output components for each model | |
fullstk_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='DSA', choices=[0, 1]), | |
gr.inputs.Radio(label='Java', choices=[0, 1]) | |
] | |
fullstk_output = gr.outputs.Label(num_top_classes=2, label='Placement Status') | |
prodengg_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='Management Skills', choices=[0, 1]), | |
gr.inputs.Radio(label='Leadership Skills', choices=[0, 1]) | |
] | |
prodengg_output = gr.outputs.Label(num_top_classes=2, label='Placement Status') | |
mkt_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='Communication Skills', choices=[0, 1]), | |
gr.inputs.Radio(label='Sales Skills', choices=[0, 1]) | |
] | |
mkt_output = gr.outputs.Label(num_top_classes=2, label='Placement Status') | |
# Create the Gradio app | |
fullstk_interface = gr.Interface( | |
fn=predict_fullstk, | |
inputs=fullstk | |