Skip to content

abhishek-maurya576/student-performance-predictor

Repository files navigation

Student Performance Predictor

Live DemoDocumentation

Advanced Machine Learning Ensemble for BCA Student Performance Prediction

Python Django scikit-learn License

A full-featured Django web application that predicts student performance categories (Low, Medium, High) using an ensemble of Random Forest, Decision Tree, and Logistic Regression models. Includes user authentication, prediction history, and an admin dashboard.

Developer: Abhishek Maurya


Screenshots

Landing Page

Results

Input Form

Input Form

Prediction Results

Results


Features

Machine Learning

  • ML Combines 3 ML models with weighted soft voting
  • Charts Real-time visualizations using Chart.js
  • Features Understand which factors matter most
  • Models Side-by-side comparison of individual models
  • AI Personalized suggestions based on predictions

User Management

  • Auth Signup/Login with enrollment number
  • Users Supports BCA, MCA, B.Tech students
  • History Save and track predictions over time
  • Dashboard View all saved predictions
  • Admin Full admin access to manage users and predictions

Technical

  • UI Responsive Bootstrap 5 interface with animations
  • Security Environment-based configuration, CSRF protection
  • Production Gunicorn + WhiteNoise for deployment

Quick Start

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)

Installation

  1. Clone the repository

    git clone https://github.com/abhishek-maurya576/student-performance-predictor.git
    cd student-performance-predictor
  2. Create virtual environment

    python -m venv venv
    venv\Scripts\activate  # Windows
    # or
    source venv/bin/activate  # Linux/Mac
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables

    copy .env.example .env  # Windows
    # or
    cp .env.example .env  # Linux/Mac
  5. Generate SECRET_KEY

    python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"

    Copy the output and paste it in .env file.

  6. Navigate to Django project

    cd student_performance_predictor
  7. Apply database migrations

    python manage.py migrate
  8. Create admin user (optional)

    python manage.py createsuperuser
  9. Run the application

    python manage.py runserver
  10. Open in browser

    http://127.0.0.1:8000/
    

    Admin panel: http://127.0.0.1:8000/admin/


Dataset Features

Academic Performance

  • Age - Student age (18-30 years)
  • CGPA Semester 1 & 2 - Cumulative GPA (0-10 scale)
  • T-1 & T-2 Marks - Test scores (0-40 scale)

Study Habits & Engagement

  • Study Hours/Week - Weekly study time
  • Attendance % - Class attendance percentage
  • Parental Support - Binary indicator
  • Extracurricular Activities - Count (0-4)
  • Online Resources Used - Binary indicator

Engineered Features

  • CGPA Average - Mean of semester CGPAs
  • T Average - Mean of test scores
  • CGPA Improvement - Semester 2 - Semester 1
  • Total Engagement - Sum of support indicators

Machine Learning Models

Ensemble Architecture

Input Features
     ↓
┌────────────────────────────────────┐
│  Feature Engineering Pipeline      │
│  - CGPA Average                    │
│  - Test Average                    │
│  - CGPA Improvement                │
│  - Total Engagement                │
└────────────────────────────────────┘
     ↓
┌────────────────────────────────────┐
│  Three Parallel Models             │
│  ┌──────────────────────────────┐  │
│  │ Random Forest (34% weight)   │  │
│  │ n_estimators=100, depth=10   │  │
│  └──────────────────────────────┘  │
│  ┌──────────────────────────────┐  │
│  │ Decision Tree (29% weight)   │  │
│  │ depth=8, entropy criterion   │  │
│  └──────────────────────────────┘  │
│  ┌──────────────────────────────┐  │
│  │ Logistic Reg. (37% weight)   │  │
│  │ max_iter=200, balanced       │  │
│  └──────────────────────────────┘  │
└────────────────────────────────────┘
     ↓
┌────────────────────────────────────┐
│  Weighted Soft Voting              │
│  final_prob = Σ(weight × prob)     │
└────────────────────────────────────┘
     ↓
  Final Prediction
  (Low/Medium/High)

Model Performance

  • Cross-Validation Accuracy: 80-87.5%
  • Ensemble Method: Weighted soft voting
  • Weights: Based on 5-fold stratified CV

Project Structure

Student_Performance_Predictor/
│
├── .env                          # Environment variables (not in git)
├── .env.example                  # Template for environment setup
├── .gitignore                    # Git ignore rules
├── requirements.txt              # Python dependencies
├── README.md                     # This file
├── render.yaml                   # Render deployment config
├── build.sh                      # Build script for deployment
│
├── training/                     # ML training pipeline
│   ├── train_models.py          # Model training script
│   ├── Training_Data.csv        # Original training dataset
│   └── Cleaned_Training_Data.csv # Preprocessed dataset
│
└── student_performance_predictor/  # Django project
    ├── manage.py
    │
    ├── predictor/               # Main Django app
    │   ├── templates/predictor/
    │   │   ├── landing.html     # Public landing page
    │   │   ├── form.html        # Prediction input form
    │   │   ├── result.html      # Results with charts
    │   │   ├── signup.html      # User registration
    │   │   ├── login.html       # User login
    │   │   └── dashboard.html   # User prediction history
    │   ├── static/predictor/
    │   │   └── style.css        # Custom styles
    │   ├── ml_models/           # Trained models
    │   │   ├── rf_model.pkl
    │   │   ├── dt_model.pkl
    │   │   ├── lr_model.pkl
    │   │   ├── scaler.pkl
    │   │   └── ensemble_config.json
    │   ├── tests/               # Unit tests
    │   │   ├── test_forms.py
    │   │   ├── test_models.py
    │   │   ├── test_views.py
    │   │   └── test_ml_pipeline.py
    │   ├── views.py             # View classes (prediction, auth, dashboard)
    │   ├── models.py            # User and Prediction models
    │   ├── forms.py             # Prediction form
    │   ├── auth_forms.py        # Registration & Login forms
    │   ├── admin.py             # Admin configuration
    │   └── urls.py              # URL routing
    │
    └── student_performance_predictor/  # Django settings
        ├── settings.py          # Configuration
        ├── urls.py              # Main URL config
        ├── wsgi.py              # WSGI config
        └── asgi.py              # ASGI config

User Interface

Landing Page

  • Attractive hero section with call-to-action
  • Feature highlights and benefits
  • Quick access to login/signup

Prediction Form

  • Clean, intuitive input form
  • Real-time validation feedback
  • Grouped sections for easy navigation
  • Responsive design for all devices

Results Page

  • Performance Prediction - Clear category display with color coding
  • Model Comparison Table - Side-by-side results from all models
  • Interactive Charts:
    • Ensemble probability distribution (doughnut chart)
    • Model prediction comparison (bar chart)
    • Feature importance visualization (horizontal bar chart)
  • Recommendations - Personalized improvement suggestions
  • Save Prediction - One-click save for authenticated users

User Dashboard

  • View all saved predictions
  • Track performance over time
  • Delete predictions
  • Admin view for all users (superuser only)

Authentication Pages

  • Signup - Register with enrollment number, email, course, and semester
  • Login - Secure login with remember me option

Technology Stack

Backend

  • Django 5.1.2 - Web framework
  • scikit-learn 1.3.2 - Machine learning
  • pandas 2.2.3 - Data manipulation
  • numpy 1.26.4 - Numerical computing
  • joblib 1.4.2 - Model serialization
  • python-decouple 3.8 - Configuration management
  • gunicorn 23.0.0 - Production WSGI server
  • whitenoise 6.8.2 - Static file serving

Frontend

  • Bootstrap 5 - UI framework
  • Chart.js - Data visualization
  • Font Awesome - Icons
  • Custom CSS - Animations and styling

Data Visualization (Training)

  • matplotlib 3.9.2 - Plotting library
  • seaborn 0.13.2 - Statistical visualizations

Model Training

To retrain the models with new data:

  1. Prepare your dataset

    • Format: CSV with required columns
    • Place in training/Training_Data.csv
  2. Run training script

    cd training
    python train_models.py
  3. Models will be saved to

    student_performance_predictor/predictor/ml_models/
    
  4. Restart Django server

    python manage.py runserver

Security

  • ✅ Environment-based configuration
  • ✅ SECRET_KEY in .env file (not committed)
  • ✅ Production security settings
  • ✅ CSRF protection enabled
  • ✅ XSS protection enabled
  • ✅ Secure cookies in production

Deployment

Heroku

# Install Heroku CLI, then:
heroku create your-app-name
heroku config:set SECRET_KEY="your-secret-key"
heroku config:set DEBUG=False
heroku config:set ALLOWED_HOSTS="your-app-name.herokuapp.com"
git push heroku main

Railway

  1. Connect your GitHub repository
  2. Set environment variables in dashboard
  3. Deploy automatically on push

Testing

Run all tests:

cd student_performance_predictor
python manage.py test predictor

Run specific test module:

python manage.py test predictor.tests.test_views
python manage.py test predictor.tests.test_models
python manage.py test predictor.tests.test_forms
python manage.py test predictor.tests.test_ml_pipeline

Database Models

User Model

Custom user model with enrollment-based authentication:

  • enrollment_number - Unique identifier (used for login)
  • email - User email (unique)
  • name - Full name
  • course - BCA, BCA-MCA(DS), MCA, B.Tech, Other
  • semester - Current semester (3-8)

Prediction Model

Stores saved predictions:

  • user - Foreign key to User
  • Input features - age, cgpa1, cgpa2, ct1_marks, ct2_marks, etc.
  • predicted_performance - Low (0), Medium (1), High (2)
  • confidence_score - Ensemble confidence percentage
  • Individual predictions - rf_prediction, dt_prediction, lr_prediction
  • Timestamps - created_at, updated_at

URL Routes

Route View Description
/ LandingPageView Public landing page
/predict/ PredictionView Prediction form (GET/POST)
/api/predict/ PredictionAPIView JSON API for charts
/signup/ SignupView User registration
/login/ LoginView User login
/logout/ LogoutView User logout
/dashboard/ DashboardView View saved predictions
/save-prediction/ SavePredictionView Save prediction to DB
/delete-prediction/<pk>/ DeletePredictionView Delete a prediction

API Documentation

Prediction API Endpoint

POST /api/predict/

Request Body (Form Data):

{
  "age": 21,
  "cgpa1": 7.5,
  "cgpa2": 8.0,
  "ct1_marks": 30,
  "ct2_marks": 35,
  "study_hours_per_week": 15,
  "attendance_percentage": 80,
  "parental_support": 1,
  "extracurricular_activities": 2,
  "online_resources_used": 1
}

Response:

{
  "final_prediction": {
    "value": 2,
    "label": "High",
    "confidence": 85.3
  },
  "model_predictions": {
    "labels": ["Random Forest", "Decision Tree", "Logistic Regression"],
    "predictions": [2, 2, 2],
    "confidences": [78.5, 82.3, 85.1]
  },
  "ensemble_probabilities": {
    "labels": ["Low", "Medium", "High"],
    "probabilities": [0.05, 0.10, 0.85]
  },
  "feature_importance": {...}
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Known Issues

  • Small dataset (50 samples) - may affect generalization
  • Chart.js version compatibility - some features deprecated

Future Enhancements

  • User authentication and authorization ✅ Implemented
  • Database integration for prediction history ✅ Implemented
  • Advanced analytics dashboard ✅ Implemented
  • Mobile app version
  • RESTful API with JWT authentication
  • Model retraining pipeline via admin
  • A/B testing for model versions
  • SHAP/LIME explainability
  • Batch prediction support
  • Export results to PDF
  • Email notifications for predictions
  • Password reset functionality
  • Social authentication (Google, GitHub)

License

This project is licensed under the MIT License - see the LICENSE file for details.


Author

Abhishek Maurya


Acknowledgments

  • scikit-learn community for ML algorithms
  • Django team for the excellent web framework
  • Chart.js for beautiful visualizations
  • Bootstrap for responsive design components

Support

If you have any questions or run into issues, please:

  1. Check the README documentation above
  2. Open an issue on GitHub
  3. Contact the developer

Show Your Support

If you found this project helpful, please give it a ⭐!


Made with ❤️ by Abhishek Maurya

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors