|
import gradio as gr |
|
from tensorflow.keras.models import load_model |
|
|
|
|
|
model = load_model("student_performance_model.h5") |
|
|
|
|
|
|
|
def predict_performance(Gender, AttendanceRate, StudyHoursPerWeek, PreviousGrade, ExtracurricularActivities, ParentalSupport): |
|
|
|
Gender_Male = 1 if Gender == 'Male' else 0 |
|
Gender_Female = 1 if Gender == 'Female' else 0 |
|
|
|
|
|
ParentalSupport_Low = 1 if ParentalSupport == 'Low' else 0 |
|
ParentalSupport_Medium = 1 if ParentalSupport == 'Medium' else 0 |
|
ParentalSupport_High = 1 if ParentalSupport == 'High' else 0 |
|
|
|
|
|
|
|
|
|
|
|
input_data = [ |
|
[Gender_Male, Gender_Female, AttendanceRate, StudyHoursPerWeek, PreviousGrade, ExtracurricularActivities, |
|
ParentalSupport_Low, ParentalSupport_Medium, ParentalSupport_High] |
|
] |
|
|
|
|
|
prediction = model.predict(input_data) |
|
return prediction[0] |
|
|
|
|
|
interface = gr.Interface( |
|
fn=predict_performance, |
|
inputs=[ |
|
gr.Dropdown(choices=['Male', 'Female'], label='Gender'), |
|
gr.Number(label='Attendance Rate (%)'), |
|
gr.Number(label='Study Hours Per Week'), |
|
gr.Number(label='Previous Grade'), |
|
gr.Slider(0, 3, step=1, label='Number of Extracurricular Activities'), |
|
gr.Dropdown(choices=['Low', 'Medium', 'High'], label='Parental Support') |
|
], |
|
outputs="text" |
|
) |
|
|
|
|
|
interface.launch() |
|
|