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()