A machine learning–powered web application for early identification of workplace depression risk.
This project presents a machine learning–based system to predict workplace depression risk using anonymized demographic, lifestyle, and work-related survey data. The primary objective is to identify employees who may be at risk of depression at an early stage, enabling timely and proactive interventions.
By leveraging supervised binary classification, the system analyzes factors such as:
- Work pressure
- Job satisfaction
- Sleep duration
- Dietary habits
- Financial stress
- Work hours
- Family mental health history
The model outputs a risk classification along with a probability score, supporting ethical and informed decision-making to improve employee well-being.
Depression in the workplace often remains undetected until it significantly affects:
- Employee productivity
- Absenteeism
- Job performance
- Staff turnover
This project addresses a critical gap in occupational health psychology by providing a data-driven and interpretable solution for early risk detection. The system is designed for integration into HR analytics platforms or Employee Assistance Programs (EAPs), with strong emphasis on:
- Ethical handling of sensitive data
- Fairness and bias awareness
- Practical deployment readiness
- Model: Logistic Regression
- Problem Type: Binary Classification
- Target Variable: Depression Risk (Yes / No)
- High interpretability for healthcare-related use cases
- Produces meaningful probability estimates
- Lower risk of overfitting compared to complex models
- Suitable for ethical and transparent decision support systems
The following preprocessing techniques are applied consistently during training and inference:
- Label Encoding for binary categorical features
- Ordinal Encoding for ordered categorical variables
- Feature scaling using
StandardScaler - Unified preprocessing pipeline to ensure prediction consistency
This project follows a full-stack architecture:
- Serves the trained ML model through an API
- Handles preprocessing, validation, and inference
- Technologies used:
- Python
- FastAPI
- scikit-learn
- Pydantic
- Interactive web interface for entering employee data
- Displays depression risk classification and probability
- Technologies used:
- React
- Vite
- JavaScript
- CSS
Workplace-Depression-Risk-Predictor/
│
├── predictor-api/ # FastAPI backend
│ ├── main.py
│ ├── models/
│ ├── requirements.txt
│ ├── Dockerfile
│ └── .dockerignore
│
├── predictor-ui/ # React frontend
│ ├── src/
│ ├── public/
│ ├── package.json
│ ├── vite.config.js
│ ├── Dockerfile
│ └── .dockerignore
│
├── dataset/ # Dataset used for training
├── notebooks/ # Model training & evaluation notebook
├── docker-compose.yml # Docker orchestration
├── .gitignore
└── README.md
git clone https://github.com/HarshaJayaweera21/Workplace-Depression-Risk-Predictor.git
cd Workplace-Depression-Risk-PredictorMake sure Docker Desktop is installed and running.
docker compose up --build| Service | URL |
|---|---|
| Frontend | http://localhost |
| Backend | http://localhost:8000 |
⚠️ Before running manually, update the following:
- In
predictor-api/main.py, add your frontend's dev server origin (e.g.,http://localhost:5173) to theallow_originslist.- Create a
predictor-ui/.envfile with:VITE_API_URL=http://127.0.0.1:8000
cd predictor-api
python -m venv .venv
.venv\Scripts\activate # On Windows
# source .venv/bin/activate # On Mac/Linux
pip install -r requirements.txt
uvicorn main:app --reload- Backend will be available at: http://127.0.0.1:8000
cd predictor-ui
npm install
npm run dev- Frontend will be available at: http://localhost:5173
- This system does not diagnose depression
- Predictions are probabilistic and intended for early risk awareness only
- Designed to support human decision-making, not replace it
- Emphasizes fairness, transparency, and responsible use of mental health data