Team Ai
Apppublic

devdut/student-performance-api

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
app.py72 linesDownload Raw Back to root
1import gradio as gr2import pickle3import numpy as np4 5# Load trained model6with open("student_model.pkl", "rb") as f:7    model = pickle.load(f)8 9# Prediction function10def predict(studytime, failures, absences, prev, mst1, mst2, est, lab):11    12    # Convert studytime from text → number13    studytime = int(studytime.split(" ")[0])14    15    # Convert failures from text → number16    failures = int(failures.split(" ")[0])17    18    data = np.array([[studytime, failures, absences, prev, mst1, mst2, est, lab]])19    20    prediction = model.predict(data)[0]21 22    if prediction == 1:23        return "Likely to Pass"24    else:25        return "At Risk of Failure"26 27# Gradio Interface28interface = gr.Interface(29    fn=predict,30    inputs=[31        gr.Radio(32            choices=[33                "1 - Less than 2 hours",34                "2 - 2 to 5 hours",35                "3 - 5 to 10 hours",36                "4 - More than 10 hours"37            ],38            label="Study Time (Weekly)"39        ),40 41        gr.Radio(42            choices=[43                "0 - No failures",44                "1 - Failed 1 subject",45                "2 - Failed 2 subjects",46                "3 - Failed 3 or more subjects"47            ],48            label="Failures (Previous Academic History)"49        ),50 51        gr.Number(label="Absences (Number of days absent)"),52 53        gr.Number(label="Previous Exam Marks (out of 100)"),54 55        gr.Number(label="MST 1 Marks (out of 20)"),56 57        gr.Number(label="MST 2 Marks (out of 20)"),58 59        gr.Number(label="End-Sem Test Marks (out of 100)"),60 61        gr.Number(label="Lab Assessment Marks (out of 30)")62    ],63    64    outputs="text",65    66    title="Advanced Student Performance Predictor",67    68    description="Predict student performance based on study behavior, attendance, and academic assessment scores."69)70 71# Launch app72interface.launch(server_name="0.0.0.0")