Spaces:
Runtime error
Runtime error
File size: 2,724 Bytes
154b7a1 e6b2bd9 dab724c e6b2bd9 |
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 |
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
|