File size: 1,730 Bytes
74199f0 | 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 | import pandas as pd
import gradio as gr
import joblib
le=joblib.load('le_col.pkl')
std=joblib.load('std_col.pkl')
lr=joblib.load('model.pkl')
le_col=['Gender', 'Parental Education Level', 'Lunch Type','Test Preparation Course']
std_col=['Study Time','Absences', 'Math Score','Reading Score', 'Writing Score']
def Prediction_model_C(G,PL,LT,TPC,ST,A,MS,RS,WC):
try:
input_data=pd.DataFrame({
'Gender':[G],
'Parental Education Level':[PL],
'Lunch Type':[LT],
'Test Preparation Course':[TPC],
'Study Time':[ST],
'Absences':[A],
'Math Score':[MS],
'Reading Score':[RS],
'Writing Score':[WC],
})
for col in le_col:
input_data[col]=le[col].transform(input_data[col])
input_data[std_col]=std.transform(input_data[std_col])
prediction=lr.predict(input_data)
return prediction[0]
except Exception as e:
return str(e)
gr.Interface(
inputs=[
gr.Dropdown(['Male','Female'],label='Gender'),
gr.Dropdown(['High School','Bachelor','Associate','Master','Some College'],label='Parental Education Level'),
gr.Dropdown(['Free/Reduced','Standard'],label='Lunch Type'),
gr.Dropdown(['Completed','NO_Completed'],label='Test Preparation Course'),
gr.Number(label='Study Time'),
gr.Number(label='Absences'),
gr.Number(label='Math Score'),
gr.Number(label='Reading Score'),
gr.Number(label='Writing Score'),
],
fn=Prediction_model_C,
outputs=gr.Textbox(label='Prediction')
).launch() |