Building a Mental Health Prediction System with Machine Learning, SHAP & Flask
Description and use
Built a web app for mental‑health risk assessment using AdaBoost, PHQ‑9, SHAP, and Flask, containerized with Docker and deployed with automated monitoring.
Problem
Develop an end‑to‑end mental‑health assessment tool that combines ML risk prediction, PHQ‑9 screening, explainability, and a web interface, moving beyond a notebook experiment.
Outcome
The project delivers a deployable mental‑health risk assessment web app with explainable predictions, PHQ‑9 integration, and support features, demonstrating a complete ML lifecycle from data to production.
Workflow
- Collect and preprocess PHQ‑9 data
- Train multiple classifiers (AdaBoost, Random Forest, XGBoost, Logistic Regression)
- Select AdaBoost (≈86.9% accuracy)
- Serialize model, transformer, and encoder
- Build Flask backend with Gunicorn
- Create HTML/CSS/Bootstrap frontend with Jinja2 templates
- Integrate SHAP to generate feature‑contribution plots
- Add counseling booking and crisis assistance pages
- Containerize app with Docker
- Deploy to Render via GitHub Actions
- Set up automated uptime monitoring
Evidence
After tuning and evaluation, the AdaBoost classifier achieved approximately 86.9% accuracy and was selected as the final model.
The application generates visual explanations showing how individual features contributed to a particular prediction.
The project also contains serialized ML artifacts such as the trained model, preprocessing transformer and label encoder.
- Record date: 2026-09-07T04:07:26.542Z