How rakesh-myana/mental-health-predictor works
Project type and purpose
• This is a full-stack, single-page Flask web application that exposes a machine-learning model for predicting the likelihood of depression.
• The user interacts with an HTML form (templates + CSS), submits data, and receives a prediction computed by Flask loading a pre-trained model (model.pkl).
File structure
• Top-level:
• app.py – Flask application entry point (routes, request handling, model invocation)
• model.pkl – serialized ML model
• requirements.txt – Python dependencies
• README.md – project description
• Directories:
• static/ – CSS and image assets
• templates/ – Jinja2 HTML templates
• training/ – Jupyter notebook and raw data for offline model training
README
• Confirms tech stack: Python + Flask + machine learning.
• Describes use case: web form → depression likelihood prediction.
Main components & relationships
a. Frontend (Client)
• Browser sends HTTP GET for landing page (templates/index.html + CSS)
• User fills form and submits via HTTP POST
b. Web Server / Backend (Flask in app.py)
• Route handlers parse input, invoke ML inference
• Loads model.pkl once or caches it in memory
• Returns JSON or rendered HTML with prediction
c. Machine Learning Model
• model.pkl lives on disk; loaded by Flask
d. (Offline) Training Pipeline
• training/training.ipynb reads mental_health_data.csv → preprocess → trains model → exports model.pkl
e. (Optional) External Infrastructure
• WSGI server (Gunicorn/uWSGI), load balancer, containerization (Docker), cloud hosting
Architectural patterns & design principles
• MVC-inspired separation: templates (View), app.py controllers (Controller), model.pkl (Model)
• Single-responsibility: training code is isolated in /training, web logic in app.py
• Stateless HTTP API for predictions
• Caching or lazy-loading of model for performance