Skip to content

AADIT9b/MLproject02

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š Student Exam Performance Indicator

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.

🎯 Features

  • 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

πŸ“‹ Requirements

Input Features

  • 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

Output

  • Predicted Math Score: Float value representing estimated math performance

πŸš€ Quick Start

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd mlprojects
  1. Create virtual environment:
# Windows
python -m venv venv
venv\Scripts\activate

# macOS/Linux
python -m venv venv
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt

Running Locally

Development mode:

python app.py

Visit: http://localhost:5000

Production mode (using Gunicorn):

gunicorn --workers 4 --bind 0.0.0.0:5000 app:app

πŸ“ Project Structure

mlprojects/
β”œβ”€β”€ 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

πŸ”§ Technology Stack

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

πŸ›‘οΈ Validation & Error Handling

Frontend Validation

  • HTML5 input constraints (min/max for scores)
  • Required field validation
  • Dropdown selections for categorical data

Backend Validation

  • 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

πŸ“Š Model Information

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

🌐 Deployment

Option 1: Heroku (Free Tier Available)

heroku login
heroku create your-app-name
git push heroku main
heroku open

Option 2: Azure App Service

az login
az webapp up --name your-app-name --resource-group myresourcegroup --runtime python:3.9 --sku B1

Option 3: Docker

docker build -t mlapp .
docker run -p 5000:5000 mlapp

For detailed deployment instructions, see DEPLOYMENT.md

πŸ“ Environment Variables

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

πŸ” How It Works

  1. User Input: Fill the form with student information
  2. Validation: Server validates all inputs (scores 0-100)
  3. Processing: Data is preprocessed using StandardScaler
  4. Prediction: ML models generate score prediction
  5. Display: Result shown with formatted output

πŸ§ͺ Testing

Test the application locally:

# Run with valid data
# Expected: Prediction displayed in green

# Run with invalid score (>100)
# Expected: Error message in red, no prediction

πŸ“š Notebooks

Data exploration and model training notebooks available:

  • 1 . EDA STUDENT PERFORMANCE .ipynb - Exploratory Data Analysis
  • 2. MODEL TRAINING.ipynb - Model training & evaluation

⚠️ Important Notes

  1. Model Files Required: Ensure artifacts/model.pkl and artifacts/preprocessor.pkl exist
  2. Production Settings:
    • Set FLASK_DEBUG=False in production
    • Use Gunicorn or similar WSGI server
    • Configure proper logging
  3. Security:
    • Never commit .env with secrets
    • Use environment variables for sensitive data
    • Validate all user inputs (already implemented)

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

πŸ“„ License

This project is licensed under the MIT License

πŸ“ž Support

For deployment help, see DEPLOYMENT.md
For issues, check error logs in logs/ directory

πŸŽ“ Learning Outcomes

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors