Ever wondered how factors like study time, attendance, sleep, and past performance affect your exam results?
This project is a simple yet powerful Machine Learning application that predicts a student's score based on these real-life factors. It’s designed to demonstrate how AI can be used in education to better understand and improve student outcomes.
As students, we often ask:
- “Am I studying enough?”
- “Does sleep really affect my performance?”
- “How much does attendance matter?”
This project tries to answer those questions using data and machine learning.
It builds a prediction model using:
- 📖 Study Hours
- 🏫 Attendance
- 😴 Sleep Hours
- 📊 Previous Scores
👉 Based on these inputs, it predicts your expected exam score.
✔ Generates realistic student data using NumPy ✔ Trains a Machine Learning model (Linear Regression) ✔ Evaluates performance using MAE and R² ✔ Interactive command-line interface ✔ Input validation to avoid errors ✔ Continuous prediction loop for multiple users
We use Linear Regression, one of the simplest and most interpretable ML algorithms.
The model learns relationships like:
- More study hours → better score 📈
- Better attendance → higher performance 🎯
- Proper sleep → improved focus 😴
score = (1.8 × study_hours) + (0.7 × attendance) +
(1.0 × sleep_hours) + (0.5 × previous_score) + noise
👉 This is not just random — it simulates realistic academic behavior.
student-performance-prediction/
│
├── main.py # Main program
├── README.md # Documentation
git clone https://github.com/your-username/student-performance-prediction.git
cd student-performance-prediction
Make sure Python (3.7 or above) is installed, then run:
pip install pandas numpy scikit-learn
Simply run:
python main.py
Enter study hours per day: 5
Enter attendance percentage: 85
Enter sleep hours per day: 7
Enter previous exam score: 70
Predicted Score: 82.45
You can keep predicting for multiple inputs — super interactive!
The model gives you:
-
Mean Absolute Error (MAE): → Average prediction error
-
R² Score: → How well the model explains the data
Example:
Mean Absolute Error: 2.45
R² Score: 0.95
👉 That means the model is quite accurate!
| Input | Range |
|---|---|
| Study Hours | 0 – 24 |
| Attendance (%) | 0 – 100 |
| Sleep Hours | 0 – 24 |
| Previous Score | 0 – 100 |
Here’s what happens step-by-step:
- Synthetic data is generated
- Data is split into training & testing sets
- Model is trained on training data
- Performance is evaluated
- Model is retrained on full data
- User inputs are used for prediction
This project can be taken much further:
- 🌐 Build a web app using Streamlit or Flask
- 📊 Add graphs & visualizations
- 📁 Use real-world datasets
- 🤖 Try advanced models (Random Forest, XGBoost)
- 💾 Save & reuse trained models
Want to improve this project? Awesome!
You can:
- Fork the repository
- Make improvements
- Submit a pull request
Big thanks to:
- The open-source community
- Libraries like Pandas, NumPy, and Scikit-learn
- Everyone exploring AI in education
If you found this project helpful or interesting:
👉 Give it a ⭐ on GitHub — it really helps!
Yuvank Bhargava 🔗 GitHub: https://github.com/yuvankbhargava82
💡 Small habits create big results — and now, you can predict them too!