!pip install pandas !pip install sklearn import gradio as gr # 🔌 Build user interface from sklearn.linear_model import LogisticRegression # 🎯 Simple ML classifier import pandas as pd # 📊 Data loading and prep # Load and prepare data Data = pd.read_csv('student_exam.csv') # Load dataset 📄 # Features and target features = ['studytime', 'failures', 'G1', 'G2'] target = 'G3' # Convert G3 to binary pass/fail Data[target] = Data[target].apply(lambda x: 1 if x >= 10 else 0) X = Data[features] y = Data[target] # Train model model = LogisticRegression(random_state=42) model.fit(X, y) # Prediction function def predict_grade(study_time, failures, g1, g2): input_data = pd.DataFrame([[study_time, failures, g1, g2]], columns=features) prediction = model.predict(input_data)[0] return "Pass ✅" if prediction == 1 else "Fail ❌" # Gradio interface demo = gr.Interface( fn=predict_grade, # Prediction function inputs=[ gr.Number(label="Study Time (1-4)"), # ⏳ How much time student spends studying gr.Number(label="Failures (0-4)"), # 📉 Number of past course failures gr.Number(label="G1 Grade (0-20)"), # 📝 First period grade gr.Number(label="G2 Grade (0-20)"), # 📝 Second period grade ], outputs=gr.Text(label="Prediction: Pass or Fail"), title="Student Exam Success Predictor", # 🎓 App Title description="Enter the student's data to predict if they will pass or fail the final exam." ) demo.launch()