Machine learning is increasingly being explored for applications in healthcare and wellbeing. However, building an ML model for a sensitive domain such as mental health requires more than simply achieving a high accuracy score.
I developed a Mental Health Prediction & Assessment System that combines machine learning, PHQ-9 screening, Explainable AI and a Flask-based web application.
The project is available on GitHub:
https://github.com/starJeet000/Mental-Health-Prediction-Using-Machine-Learning
What Is the Project?
The application is designed as an educational and preliminary screening system that evaluates mental-health-related information and produces a risk prediction.
It combines an ML-based prediction system with a standardized PHQ-9 questionnaire.
The purpose is not to replace mental-health professionals but to demonstrate how machine learning can be incorporated into a complete software application.
Machine Learning Model
Several classification algorithms were trained and evaluated:
- AdaBoost
- Random Forest
- XGBoost
- Logistic Regression
After model evaluation and tuning, the AdaBoost classifier achieved approximately 86.9% accuracy and was selected as the final model.
The models were evaluated using metrics and visualizations including confusion matrices, ROC-AUC and precision-recall analysis.
PHQ-9 Screening
The project also integrates the Patient Health Questionnaire-9 (PHQ-9).
PHQ-9 provides a standardized score between 0 and 27 based on nine questions.
The application uses this screening information alongside the machine-learning prediction to create an additional safety-oriented layer.
Explainable AI Using SHAP
One of the most important features of the project is Explainable AI.
Machine-learning models can sometimes behave like black boxes. A prediction without an explanation can be difficult to interpret.
To address this, the project uses SHAP, which generates visual explanations showing the contribution of individual features to a prediction.
This makes it possible to investigate not only what the model predicted, but also which factors influenced the prediction.
The project uses:
- Python
- Pandas
- NumPy
- Scikit-learn
- XGBoost
- SHAP
- Flask
- Gunicorn
- HTML5
- CSS3
- Bootstrap
- Jinja2
- Docker
- Render
- GitHub Actions
Application Features
The application includes several features beyond the ML model:
- Mental-health risk prediction
- PHQ-9 screening
- SHAP-based explanations
- Interactive web interface
- Counselling booking interface
- Crisis assistance information
- Docker deployment
- Automated uptime monitoring
The repository contains the Flask backend, ML artifacts, training notebook, dataset, templates, static assets and Docker configuration.
Why Explainability Matters
In sensitive applications, simply returning:
"Prediction: High Risk"
isn't enough.
Users and developers should be able to understand the factors that influenced the model.
Explainable AI techniques such as SHAP can help developers inspect model behavior and identify potentially important features.
Lessons From the Project
This project demonstrated that an ML application involves much more than model training.
A complete system requires:
Data → Preprocessing → Model → Evaluation → Explainability → Backend → UI → Deployment
It also requires careful consideration of limitations and responsible communication.
Final Thoughts
The project was an opportunity to combine Machine Learning, Explainable AI, Flask and DevOps into a single application.
The most important takeaway is that when machine learning is applied to sensitive areas, responsibility and transparency should be considered alongside performance.
⚠️ Disclaimer: This project is for educational and preliminary screening purposes only. It is not a substitute for professional medical advice, diagnosis or treatment.
Project Repository
https://github.com/starJeet000/Mental-Health-Prediction-Using-Machine-Learning


Comments
Post a Comment
Thanks for reading! Feel free to drop a question or feedback