Skip to content

rushielevates/FAILSAFE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ FAILSAFE β€” Early Warning System for At-Risk Students

Predict student failure BEFORE it happens β€” with Explainable AI and Auto-Generated Intervention Plans.


🎯 Problem Statement

In educational institutions, student failure often goes undetected until end-of-semester results, leaving no room for meaningful intervention. Faculty lack a proactive, data-driven tool to identify at-risk students early.


πŸ’‘ Solution

FAILSAFE is a web-based system where faculty upload student data and a trained ML model predicts failure risk β€” with Explainable AI (SHAP) making every prediction transparent β€” and auto-generated intervention plans guiding support.


πŸš€ Live Demo

Component URL
Frontend failsafe-App
Backend API failsafe-api-wvs6.onrender.com

🧠 Machine Learning Model

Dataset

  • UCI Student Performance Dataset β€” 649 students, 33 features
  • Combined Math (student-mat.csv) and Portuguese (student-por.csv) courses

Features Used (32 total)

Category Features
Academic G1, G2 (period grades), failures, studytime
Attendance absences, traveltime
Behavioral Dalc, Walc (alcohol), goout, freetime, romantic
Family Pstatus, famsup, famrel, Medu, Fedu, Mjob, Fjob
Demographics age, sex, address, famsize, school

Model Architecture

XGBoost Classifier + SMOTEENN (Handling Imbalance)
β”œβ”€β”€ SMOTE: Synthetic Minority Oversampling
β”œβ”€β”€ ENN: Edited Nearest Neighbors (noise removal)
└── Threshold Tuning: Optimal F2-score threshold

Performance

Metric Score
Accuracy 92%
Fail Recall 95% πŸ”₯
ROC-AUC 0.956
False Alarms 16 (acceptable)

Handling Imbalance

  • Original ratio: 5.5:1 (Pass:Fail)
  • SMOTEENN applied β†’ Balanced training data
  • Threshold tuned to 0.55 for optimal fail detection

πŸ” Explainable AI (SHAP)

Every prediction comes with 5 SHAP risk factors explaining exactly WHY a student is flagged:

Feature Impact Direction
G2 -4.59 πŸ”΄ Risk
absences -0.34 πŸ”΄ Risk
studytime +0.28 🟒 Protective

Faculty see human-readable explanations:

  • πŸ”΄ G2=4 β†’ Strong risk factor
  • πŸ”΄ absences=15 β†’ Moderate risk
  • 🟒 studytime=4 β†’ Protective factor

πŸ“‹ Auto-Generated Intervention Plans

Based on SHAP risk factors, the system generates personalised action plans:

Risk Factor Intervention Priority
Low G1/G2 Schedule remedial classes High
High absences Attendance monitoring program High
Alcohol (Dalc/Walc) Counselor referral High
Past failures Assign academic mentor High
Family factors Parent-teacher meeting Medium

Each plan includes: Action β†’ Detail β†’ Priority β†’ Timeline


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         React Frontend (Vercel)                         β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚ β”‚ Upload   β”‚ β”‚Dashboard β”‚ β”‚ Intervention Tracker  β”‚   β”‚
β”‚ β”‚ Module   β”‚ β”‚ & Charts β”‚ β”‚                       β”‚   β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚ REST API
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       FastAPI Backend (Render)                          β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚ β”‚ Auth     β”‚ β”‚ ML Model β”‚ β”‚ Intervention         β”‚    β”‚
β”‚ β”‚ Service  β”‚ β”‚ Service  β”‚ β”‚ Generator            β”‚    β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    PostgreSQL (Supabase Cloud)                          β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚ β”‚ Users    β”‚ β”‚Predictionsβ”‚ β”‚ Students            β”‚    β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Layer Technology
Frontend React.js, Recharts, Axios
Backend FastAPI, Python 3.11
ML XGBoost, SHAP, Scikit-learn, Imbalanced-learn
Database PostgreSQL (Supabase)
Auth JWT, bcrypt
Deployment Vercel (Frontend), Render (Backend)

πŸ“ Project Structure

FAILSAFE/
β”œβ”€β”€ failsafe-backend/
β”‚   β”œβ”€β”€ main.py                          # FastAPI entry point
β”‚   β”œβ”€β”€ requirements.txt                 # Python dependencies
β”‚   β”œβ”€β”€ runtime.txt                      # Python version for Render
β”‚   β”œβ”€β”€ models/                          # Trained model files
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ model_loader.py             # Load model & pipeline
β”‚   β”‚   β”œβ”€β”€ preprocessing.py            # Data preprocessing
β”‚   β”‚   β”œβ”€β”€ pipeline.py                 # CompletePipeline class
β”‚   β”‚   β”œβ”€β”€ intervention.py             # Intervention generator
β”‚   β”‚   └── auth.py                     # JWT authentication
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ predict.py                  # Prediction endpoints
β”‚   β”‚   └── auth.py                     # Login/signup endpoints
β”‚   └── database/
β”‚       β”œβ”€β”€ connection.py               # Supabase connection
β”‚       └── models.py                   # Database tables
β”‚
β”œβ”€β”€ failsafe-frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx           # Main dashboard
β”‚   β”‚   β”‚   └── LoginPage.jsx           # Authentication
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   └── RiskChart.jsx           # Pie & Bar charts
β”‚   β”‚   └── App.jsx                     # Router setup
β”‚   └── package.json
β”‚
β”œβ”€β”€ colab_notebooks/
β”‚   └── failsafe_model.ipynb            # Model training notebook
β”‚
└── README.md

πŸ”§ Local Setup

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • Supabase account (free)
  • Git

Backend Setup

cd failsafe-backend
python -m venv failsafe_env
# On Windows:
failsafe_env\Scripts\activate
# On macOS/Linux:
source failsafe_env/bin/activate

pip install -r requirements.txt
uvicorn main:app --reload

Frontend Setup

cd failsafe-frontend
npm install
npm run dev

Environment Variables (.env)

DATABASE_URL=postgresql://user:pass@host:6543/postgres
SECRET_KEY=your-secret-key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

🎯 Goals Achieved

Goal Status
Predict at-risk students using attendance, assignments & behavioral data βœ…
SHAP explanations for every prediction βœ…
Auto-generated personalised intervention plans βœ…
Faculty & HOD dashboard with risk trends βœ…

πŸ‘¨β€πŸ’» Author

Built with ❀️ as part of the FAILSAFE project.

About

Early Warning System for At-Risk Students using ML + XAI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors