DetectiveShadow commited on
Commit
a1af789
·
verified ·
1 Parent(s): 5440fed

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from sklearn.model_selection import train_test_split
3
+ from sklearn.linear_model import LinearRegression
4
+ from sklearn.metrics import mean_absolute_error, r2_score
5
+
6
+ # Load your dataset
7
+ df = pd.read_excel("Book 1 (1).xlsx")
8
+
9
+ # Select features (X) and target (y)
10
+ # You can adjust this list depending on what you want to use
11
+ features = ["Attendance", "Hours studied", "Quizzes_avg", "Confidence"]
12
+ X = df[features]
13
+ y = df["Final Grade"]
14
+
15
+ # Split data into train and test sets
16
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
17
+
18
+ # Train a regression model
19
+ model = LinearRegression()
20
+ model.fit(X_train, y_train)
21
+
22
+ # Make predictions
23
+ y_pred = model.predict(X_test)
24
+
25
+ # Evaluate
26
+ print("Mean Absolute Error:", mean_absolute_error(y_test, y_pred))
27
+ print("R² Score:", r2_score(y_test, y_pred))
28
+
29
+ # Example: predict grade for a new student
30
+ sample = pd.DataFrame([{
31
+ "Attendance": 0.95,
32
+ "Hours studied": 12,
33
+ "Quizzes_avg": 85,
34
+ "Confidence": 7
35
+ }])
36
+ print("Predicted grade:", model.predict(sample)[0])