PowerCompute750 commited on
Commit
d40e39e
·
verified ·
1 Parent(s): 69bada1

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +34 -0
  2. model.pkl +3 -0
  3. requirements.txt +5 -0
  4. train_model.py +33 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pickle
3
+ import numpy as np
4
+
5
+ # Load model
6
+ with open("model.pkl", "rb") as f:
7
+ model = pickle.load(f)
8
+
9
+ def predict_pass(study_hours, attendance, assignments_completed, previous_marks):
10
+
11
+ data = np.array([[study_hours, attendance, assignments_completed, previous_marks]])
12
+
13
+ prediction = model.predict(data)[0]
14
+
15
+ if prediction == 1:
16
+ return "✅ Student Will PASS"
17
+ else:
18
+ return "❌ Student Will FAIL"
19
+
20
+ # Gradio UI
21
+ interface = gr.Interface(
22
+ fn=predict_pass,
23
+ inputs=[
24
+ gr.Number(label="Study Hours"),
25
+ gr.Number(label="Attendance (%)"),
26
+ gr.Number(label="Assignments Completed"),
27
+ gr.Number(label="Previous Marks")
28
+ ],
29
+ outputs="text",
30
+ title="🎓 Student Pass/Fail Predictor",
31
+ description="Predict whether a student will pass based on study hours, attendance, assignments, and previous marks."
32
+ )
33
+
34
+ interface.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4328f560626c678b471f1d54c9aebd7cd4ccadd3ac6aba09b45f649ae1b43686
3
+ size 73628
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ xgboost
3
+ scikit-learn
4
+ pandas
5
+ numpy
train_model.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import xgboost as xgb
2
+ import pandas as pd
3
+ import pickle
4
+ from sklearn.model_selection import train_test_split
5
+
6
+ data = {
7
+ "study_hours": [1,2,3,4,5,6,7,8,2,3,5,6,7,1,4],
8
+ "attendance": [50,55,60,65,70,75,80,85,60,65,75,80,85,45,68],
9
+ "assignments_completed": [1,1,2,2,3,3,4,4,2,2,3,3,4,1,2],
10
+ "previous_marks": [30,35,40,45,50,55,60,65,42,48,53,58,62,28,47],
11
+ "pass": [0,0,0,0,1,1,1,1,0,0,1,1,1,0,0]
12
+ }
13
+
14
+ df = pd.DataFrame(data)
15
+
16
+ X = df.drop("pass", axis=1)
17
+ y = df["pass"]
18
+
19
+ X_train, X_test, y_train, y_test = train_test_split(
20
+ X, y, test_size=0.2, random_state=42
21
+ )
22
+
23
+ model = xgb.XGBClassifier(
24
+ objective="binary:logistic",
25
+ eval_metric="logloss",
26
+ use_label_encoder=False
27
+ )
28
+
29
+ model.fit(X_train, y_train)
30
+ with open("model.pkl", "wb") as f:
31
+ pickle.dump(model, f)
32
+
33
+ print("Model saved as model.pkl")