An end-to-end Machine Learning system that predicts a student's Math score based on demographic and academic features. The project includes a full ML pipeline, model training with multiple algorithms, hyperparameter tuning, and deployment-ready APIs using FastAPI and Streamlit.
Students' academic performance depends on multiple factors such as:
- Parental education
- Test preparation
- Gender & ethnicity
- Reading & writing skills
This project predicts a student's math score using these features.
User (Browser)
β
Streamlit Frontend (Streamlit Cloud)
β
FastAPI Backend on Render (/predict)
β
Predict Pipeline (Preprocessing + Model)
β
Trained ML Model (.pkl)
β
Prediction Output
- Python
- Pandas
- NumPy
- Scikit-learn
- XGBoost
- CatBoost
- GridSearchCV
- Data Ingestion
- Data Transformation (Pipeline + ColumnTransformer)
- Model Training (7 algorithms comparison)
- Hyperparameter tuning
- FastAPI β Backend API, deployed on Render
- Streamlit β Frontend UI, deployed on Streamlit Cloud
- Load dataset
- Train-test split
- Missing value handling
- OneHotEncoding
- Standardization
- Saved as
preprocessor.pkl
Trained 7 regression models:
-
Linear Regression
-
Random Forest
-
Decision Tree
-
Gradient Boosting
-
XGBoost
-
CatBoost
-
AdaBoost
-
Hyperparameter tuning using GridSearchCV
-
Best model saved as
model.pkl
- Loads saved model + preprocessor
- Transforms input data
- Returns prediction
GET /
Response:
{ "message": "API is running" }POST /predict
Input:
{
"gender": "male",
"race_ethnicity": "group B",
"parental_level_of_education": "bachelor's degree",
"lunch": "standard",
"test_preparation_course": "completed",
"reading_score": 72,
"writing_score": 70
}Output:
{
"predicted_math_score": 78.45
}Features:
- Interactive form input
- Real-time prediction
- Clean UI with dropdowns and sliders
- API-based communication with FastAPI backend
- Best Model: Linear Regression
- RΒ² Score: ~0.88
- Hyperparameter tuning improved performance significantly
The FastAPI backend is deployed on Render.
- Render automatically builds and runs the FastAPI app from the repository
- Uses
uvicornas the ASGI server - Start Command:
uvicorn src.api.main:app --host 0.0.0.0 --port 10000
The Streamlit frontend is deployed on Streamlit Cloud.
- Connects directly to the GitHub repository
- Reads
requirements.txtfor dependencies - The API base URL in
app.pyshould point to the deployed Render backend URL
git clone https://github.com/your-username/MLproject.git
cd MLprojectpython -m venv venv
source venv/bin/activate # Mac/Linux
venv\Scripts\activate # Windowspip install -r requirements.txtpython -m src.pipeline.train_pipelineuvicorn src.api.main:app --reloadstreamlit run app.pyβ End-to-end ML pipeline
β Multiple model comparison
β Hyperparameter tuning
β Modular code structure
β FastAPI backend β deployed on Render
β Streamlit frontend β deployed on Streamlit Cloud
β Production-ready architecture
Give it a β on GitHub and feel free to fork it!