An end-to-end machine learning project that predicts a student's math score from a small profile: gender, ethnicity group, parental education, lunch type, test prep course, reading score, and writing score.
The project includes:
- Data ingestion and preprocessing pipelines
- Model training and evaluation
- Serialized preprocessing and model artifacts
- A Flask web application for prediction
- A polished frontend for interactive input and result display
This repository demonstrates a complete ML workflow:
- Raw student performance data is prepared and cleaned.
- A preprocessing pipeline transforms categorical and numeric features.
- Multiple regression models are evaluated.
- The best model and preprocessor are saved to the
artifacts/folder. - A Flask application loads those artifacts and serves predictions through a browser UI.
- Predicts math score from seven input features
- Uses a trained preprocessing pipeline and regression model
- Simple browser-based interface built with Flask and HTML/CSS/JavaScript
- Persistent training artifacts for inference reuse
- Modular source code organized by responsibility
.
|-- app.py
|-- README.md
|-- requirements.txt
|-- setup.py
|-- artifacts/
|-- data/
|-- logs/
|-- notebook/
|-- src/
| |-- exception.py
| |-- logger.py
| |-- utils.py
| |-- components/
| | |-- data_ingestion.py
| | |-- data_transformation.py
| | `-- model_trainer.py
| `-- pipeline/
| |-- predict_pipeline.py
| `-- train_pipeline.py
`-- templates/
`-- home.html
- Python 3.10+ recommended
- A virtual environment is strongly recommended
- Packages listed in
requirements.txt
Open the project folder in VS Code or clone it locally.
On Windows PowerShell:
python -m venv .venv
.venv\Scripts\activatepip install -r requirements.txtIf you prefer editable installation for the local package:
pip install -e .Start the Flask app from the project root:
.venv\Scripts\python.exe app.pyThen open the prediction page in your browser:
http://127.0.0.1:5000/predictdata
The web form sends the following values to the backend:
genderrace_ethnicityparental_level_of_educationlunchtest_preparation_coursereading_scorewriting_score
The backend converts the input into a pandas DataFrame, applies the saved preprocessor, and uses the saved model to generate a math score prediction.
The training pipeline stores reusable objects in artifacts/:
model.pkl- trained regression modelpreprocessor.pkl- preprocessing pipelinetrain.csvandtest.csv- processed train/test data splits
These artifacts allow the Flask app to run inference without retraining.
- The project uses a custom exception class and logging helper under
src/ - Training and inference are separated into different pipeline modules
- The frontend is rendered with Flask templates and standard browser JavaScript
- If the app does not start, confirm that the virtual environment is activated and dependencies are installed.
- If prediction fails, make sure the
artifacts/folder contains the trained model and preprocessor files. - If you see schema-related errors, ensure the frontend field names match the backend feature names.
This project is licensed under the MIT License.
Akshat Kumar Singh