Download app.py from DetectiveShadow/Grade_predictor: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/DetectiveShadow/Grade_predictor/resolve/main/app.py
- Command line
-
hf download hf://DetectiveShadow/Grade_predictor/app.py
-
curl -L -o app.py https://huggingface.co/DetectiveShadow/Grade_predictor/resolve/main/app.py
1.06 kB
| import pandas as pd | |
| from sklearn.model_selection import train_test_split | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.metrics import mean_absolute_error, r2_score | |
| # Load your dataset | |
| df = pd.read_excel("Book 1 (1).xlsx") | |
| # Select features (X) and target (y) | |
| # You can adjust this list depending on what you want to use | |
| features = ["Attendance", "Hours studied", "Quizzes_avg", "Confidence"] | |
| X = df[features] | |
| y = df["Final Grade"] | |
| # Split data into train and test sets | |
| X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) | |
| # Train a regression model | |
| model = LinearRegression() | |
| model.fit(X_train, y_train) | |
| # Make predictions | |
| y_pred = model.predict(X_test) | |
| # Evaluate | |
| print("Mean Absolute Error:", mean_absolute_error(y_test, y_pred)) | |
| print("R² Score:", r2_score(y_test, y_pred)) | |
| # Example: predict grade for a new student | |
| sample = pd.DataFrame([{ | |
| "Attendance": 0.95, | |
| "Hours studied": 12, | |
| "Quizzes_avg": 85, | |
| "Confidence": 7 | |
| }]) | |
| print("Predicted grade:", model.predict(sample)[0]) | |