Kla007/Student-performance-analysis
0
1import gradio as gr2import joblib3import numpy as np4import pandas as pd5 6# Load the model and unique brand values7model = joblib.load('model.joblib')8# Assuming unique_values contains the unique values for each categorical variable9unique_values = joblib.load('unique_values.joblib')10 11# Define the prediction function12def predict(age, gender, ethnicity, parental_education, study_time_weekly, absences, tutoring, parental_support, extracurricular, sports, music, volunteering):13 # Convert inputs to appropriate types (if necessary)14 # ... (if any inputs need conversion)15 16 # Prepare the input array for prediction17 input_data = pd.DataFrame({18 'Age': [age],19 'Gender': [gender],20 'Ethnicity': [ethnicity],21 'Parental Education': [parental_education],22 'Study Time Weekly': [study_time_weekly],23 'Absences': [absences],24 'Tutoring': [tutoring],25 'Parental Support': [parental_support],26 'Extracurricular': [extracurricular],27 'Sports': [sports],28 'Music': [music],29 'Volunteering': [volunteering]30 })31 32 # Perform the prediction33 prediction = model.predict(input_data)34 35 return prediction[0]36 37# Create the Gradio interface38interface = gr.Interface(39 fn=predict,40 inputs=[41 gr.Textbox(label="Age"),42 gr.Textbox(label="Gender"),43 gr.Textbox(label="Ethnicity"),44 gr.Textbox(label="Parental Education"),45 gr.Textbox(label="Study Time Weekly"),46 gr.Textbox(label="Absences"),47 gr.Textbox(label="Tutoring"),48 gr.Textbox(label="Parental Support"),49 gr.Textbox(label="Extracurricular"),50 gr.Textbox(label="Sports"),51 gr.Textbox(label="Music"),52 gr.Textbox(label="Volunteering")53 ],54 outputs="text",55 title="Predictor",56 description="Enter the relevant information to predict the target value."57)58 59# Launch the app60interface.launch()