Advanced Machine Learning Ensemble for BCA Student Performance Prediction
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
Combines 3 ML models with weighted soft voting
Real-time visualizations using Chart.js
Understand which factors matter most
Side-by-side comparison of individual models
Personalized suggestions based on predictions
Signup/Login with enrollment number
Supports BCA, MCA, B.Tech students
Save and track predictions over time
View all saved predictions
Full admin access to manage users and predictions
Responsive Bootstrap 5 interface with animations
Environment-based configuration, CSRF protection
Gunicorn + WhiteNoise for deployment
- Python 3.8 or higher
- pip (Python package manager)
-
Clone the repository
git clone https://github.com/abhishek-maurya576/student-performance-predictor.git cd student-performance-predictor -
Create virtual environment
python -m venv venv venv\Scripts\activate # Windows # or source venv/bin/activate # Linux/Mac
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
copy .env.example .env # Windows # or cp .env.example .env # Linux/Mac
-
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
.envfile. -
Navigate to Django project
cd student_performance_predictor -
Apply database migrations
python manage.py migrate
-
Create admin user (optional)
python manage.py createsuperuser
-
Run the application
python manage.py runserver
-
Open in browser
http://127.0.0.1:8000/Admin panel:
http://127.0.0.1:8000/admin/
- 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 Hours/Week - Weekly study time
- Attendance % - Class attendance percentage
- Parental Support - Binary indicator
- Extracurricular Activities - Count (0-4)
- Online Resources Used - Binary indicator
- CGPA Average - Mean of semester CGPAs
- T Average - Mean of test scores
- CGPA Improvement - Semester 2 - Semester 1
- Total Engagement - Sum of support indicators
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)
- Cross-Validation Accuracy: 80-87.5%
- Ensemble Method: Weighted soft voting
- Weights: Based on 5-fold stratified CV
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
- Attractive hero section with call-to-action
- Feature highlights and benefits
- Quick access to login/signup
- Clean, intuitive input form
- Real-time validation feedback
- Grouped sections for easy navigation
- Responsive design for all devices
- 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
- View all saved predictions
- Track performance over time
- Delete predictions
- Admin view for all users (superuser only)
- Signup - Register with enrollment number, email, course, and semester
- Login - Secure login with remember me option
- 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
- Bootstrap 5 - UI framework
- Chart.js - Data visualization
- Font Awesome - Icons
- Custom CSS - Animations and styling
- matplotlib 3.9.2 - Plotting library
- seaborn 0.13.2 - Statistical visualizations
To retrain the models with new data:
-
Prepare your dataset
- Format: CSV with required columns
- Place in
training/Training_Data.csv
-
Run training script
cd training python train_models.py -
Models will be saved to
student_performance_predictor/predictor/ml_models/ -
Restart Django server
python manage.py runserver
- ✅ Environment-based configuration
- ✅ SECRET_KEY in .env file (not committed)
- ✅ Production security settings
- ✅ CSRF protection enabled
- ✅ XSS protection enabled
- ✅ Secure cookies in production
# 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- Connect your GitHub repository
- Set environment variables in dashboard
- Deploy automatically on push
Run all tests:
cd student_performance_predictor
python manage.py test predictorRun 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_pipelineCustom 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)
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
| 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 |
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": {...}
}Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Small dataset (50 samples) - may affect generalization
- Chart.js version compatibility - some features deprecated
-
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)
This project is licensed under the MIT License - see the LICENSE file for details.
Abhishek Maurya
- GitHub: @abhishek-maurya576
- LinkedIn: Your LinkedIn
- Email: maurya972137@gmail.com
- scikit-learn community for ML algorithms
- Django team for the excellent web framework
- Chart.js for beautiful visualizations
- Bootstrap for responsive design components
If you have any questions or run into issues, please:
- Check the README documentation above
- Open an issue on GitHub
- Contact the developer
If you found this project helpful, please give it a ⭐!
Made with ❤️ by Abhishek Maurya


