Skip to content

About

A full-stack AI/ML web application for predicting workplace depression risk using a Logistic Regression model trained on demographic, work, and lifestyle factors. The system uses FastAPI for backend inference and a React (Vite) frontend for user interaction.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

Repository files navigation

🧠 Workplace Depression Risk Predictor

A machine learning–powered web application for early identification of workplace depression risk.


📸 Application Interface

📝 Input Form

Screenshot 2026-01-13 013950 Screenshot 2026-01-13 014017

📊 Prediction Result

Screenshot 2026-01-13 014354

📌 Overview

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.


🎯 Problem Motivation

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

🧪 Machine Learning Approach

  • Model: Logistic Regression
  • Problem Type: Binary Classification
  • Target Variable: Depression Risk (Yes / No)

Why Logistic Regression?

  • 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

🔧 Data Preprocessing

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

🏗️ System Architecture

This project follows a full-stack architecture:

🔹 Backend — FastAPI

  • Serves the trained ML model through an API
  • Handles preprocessing, validation, and inference
  • Technologies used:
    • Python
    • FastAPI
    • scikit-learn
    • Pydantic

🔹 Frontend — React

  • Interactive web interface for entering employee data
  • Displays depression risk classification and probability
  • Technologies used:
    • React
    • Vite
    • JavaScript
    • CSS

📁 Project Structure

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

▶️ How to Run the Project Locally

1️⃣ Clone the Repository

git clone https://github.com/HarshaJayaweera21/Workplace-Depression-Risk-Predictor.git
cd Workplace-Depression-Risk-Predictor

Option A: Using Docker (Recommended)

Make sure Docker Desktop is installed and running.

docker compose up --build
Service URL
Frontend http://localhost
Backend http://localhost:8000

Option B: Manual Setup

⚠️ Before running manually, update the following:

  • In predictor-api/main.py, add your frontend's dev server origin (e.g., http://localhost:5173) to the allow_origins list.
  • Create a predictor-ui/.env file with: VITE_API_URL=http://127.0.0.1:8000

2️⃣ Run the Predictor API (FastAPI)

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

3️⃣ Run the Predictor UI (React)

cd predictor-ui
npm install
npm run dev

⚠️ Ethical Considerations

  • 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

About

A full-stack AI/ML web application for predicting workplace depression risk using a Logistic Regression model trained on demographic, work, and lifestyle factors. The system uses FastAPI for backend inference and a React (Vite) frontend for user interaction.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages