A machine learning web application that predicts student math scores based on various educational and demographic factors. Built with Flask and scikit-learn, this project provides an intuitive interface for predicting exam performance.
- Accurate Predictions: Uses trained ML models to predict math scores
- Beautiful UI: Modern, responsive design with gradient backgrounds
- Input Validation: Comprehensive client-side and server-side validation
- Error Handling: Robust exception handling with user-friendly error messages
- Production Ready: Configured for cloud deployment (Azure, Heroku, AWS, GCP)
- Real-time Results: Instant predictions with formatted output
- Gender: Male / Female
- Race/Ethnicity: Group A, B, C, D, or E
- Parental Education Level: High School, Some College, Bachelor's, Master's Degree
- Lunch Type: Standard or Free/Reduced
- Test Preparation Course: Completed or None
- Reading Score: 0-100
- Writing Score: 0-100
- Predicted Math Score: Float value representing estimated math performance
- Clone the repository:
git clone <your-repo-url>
cd mlprojects- Create virtual environment:
# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python -m venv venv
source venv/bin/activate- Install dependencies:
pip install -r requirements.txtDevelopment mode:
python app.pyVisit: http://localhost:5000
Production mode (using Gunicorn):
gunicorn --workers 4 --bind 0.0.0.0:5000 app:appmlprojects/
βββ app.py # Flask application entry point
βββ requirements.txt # Python dependencies
βββ Procfile # Heroku deployment config
βββ .env # Environment variables
βββ README.md # This file
βββ DEPLOYMENT.md # Detailed deployment guide
β
βββ src/
β βββ __init__.py
β βββ exception.py # Custom exception handling
β βββ logger.py # Logging configuration
β βββ utils.py # Utility functions
β β
β βββ components/
β β βββ data_ingestion.py # Data loading
β β βββ data_transformation.py # Data preprocessing
β β βββ model_trainer.py # Model training
β β
β βββ pipeline/
β βββ train_pipeline.py # Training workflow
β βββ predict_pipeline.py # Prediction workflow
β
βββ templates/
β βββ home.html # Prediction form & results
β βββ index.html # Home page
β
βββ artifacts/
β βββ model.pkl # Trained ML model
β βββ preprocessor.pkl # Data preprocessor/scaler
β
βββ notebook/
β βββ 1 . EDA STUDENT PERFORMANCE .ipynb
β βββ 2. MODEL TRAINING.ipynb
β
βββ logs/ # Application logs
| Component | Technology |
|---|---|
| Backend | Flask (Python) |
| ML Models | scikit-learn, CatBoost, XGBoost |
| Data Processing | Pandas, NumPy |
| Server | Gunicorn |
| Frontend | HTML5, CSS3 (Responsive Design) |
| Deployment | Docker, Heroku, Azure App Service |
- HTML5 input constraints (min/max for scores)
- Required field validation
- Dropdown selections for categorical data
- Score Range Check: Reading & Writing scores must be 0-100
- Custom Exceptions: Detailed error messages with file & line info
- Error Logging: All errors logged with timestamps
- Graceful Fallback: User-friendly error messages
The application uses ensemble models trained on student performance data:
- Primary Models: CatBoost, XGBoost, scikit-learn estimators
- Preprocessing: StandardScaler for feature normalization
- Accuracy: Validated on test dataset
Trained models are located in artifacts/ directory
heroku login
heroku create your-app-name
git push heroku main
heroku openaz login
az webapp up --name your-app-name --resource-group myresourcegroup --runtime python:3.9 --sku B1docker build -t mlapp .
docker run -p 5000:5000 mlappFor detailed deployment instructions, see DEPLOYMENT.md
Create a .env file in root directory:
FLASK_DEBUG=False # Set to True for development only
PORT=5000 # Server port
FLASK_ENV=production # Set to development for debug mode- User Input: Fill the form with student information
- Validation: Server validates all inputs (scores 0-100)
- Processing: Data is preprocessed using StandardScaler
- Prediction: ML models generate score prediction
- Display: Result shown with formatted output
Test the application locally:
# Run with valid data
# Expected: Prediction displayed in green
# Run with invalid score (>100)
# Expected: Error message in red, no predictionData exploration and model training notebooks available:
1 . EDA STUDENT PERFORMANCE .ipynb- Exploratory Data Analysis2. MODEL TRAINING.ipynb- Model training & evaluation
- Model Files Required: Ensure
artifacts/model.pklandartifacts/preprocessor.pklexist - Production Settings:
- Set
FLASK_DEBUG=Falsein production - Use Gunicorn or similar WSGI server
- Configure proper logging
- Set
- Security:
- Never commit
.envwith secrets - Use environment variables for sensitive data
- Validate all user inputs (already implemented)
- Never commit
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License
For deployment help, see DEPLOYMENT.md
For issues, check error logs in logs/ directory
This project demonstrates:
- β Flask web application development
- β ML model deployment
- β Exception handling & logging
- β Form validation (client & server-side)
- β Cloud deployment (Heroku, Azure, Docker)
- β Production-ready code practices
Status: β
Ready for Deployment
Last Updated: March 2026
Version: 1.0.0