Skip to content

Rupkatha-dev/Employee_Burnout_Analysis

Repository files navigation

Employee Burnout Analysis and Prediction

This repository provides an end-to-end machine learning solution for analyzing and predicting employee burnout rates. It combines a robust data science pipeline built in Python with a highly interactive, responsive, and lightweight client-side prediction dashboard designed for real-time web deployment.

Live demo: https://employee-burnout-analysis-v5wi.vercel.app/

By utilizing a dataset of 22,750 employee records, the project trains a high-accuracy predictive model. The model parameters are then exported to a lightweight configuration, allowing the client-side JavaScript engine to compute predictions instantly in the browser without any server latency or backend API requirements.


Key Features

  • High Performance Model: Powered by a Linear Regression model achieving an R2 score of approximately 89.73% on test data.
  • Robust Preprocessing: Implements K-Nearest Neighbors (KNN) imputation for missing data and standard scaling to ensure input consistency.
  • Serverless Client-Side Predictions: Replicates the scikit-learn standard scaling and model inference pipelines in pure browser-based JavaScript using a compiled JSON configuration.
  • Premium User Interface: Modern dashboard built with vanilla HTML5 and CSS3, featuring background ambient glow effects, responsive glassmorphic cards, custom slider elements, and an interactive, animated SVG radial gauge.
  • Explainable Insights: Provides immediate feedback on how changes to work allocation, designation levels, and mental fatigue scores directly affect overall burnout metrics.

Project Structure

├── app/
│   ├── css/
│   │   └── style.css            # Custom vanilla CSS featuring modern glassmorphism and animations
│   ├── js/
│   │   └── app.js               # Client-side scaling, dot product inference, and UI rendering engine
│   ├── index.html               # Main dashboard HTML5 markup
│   └── model_params.json        # Compiled model coefficients, intercept, and scaler parameters
├── Employee_Burn_Out_Analysis.ipynb # Jupyter Notebook containing exploratory data analysis and initial training
├── export_model.py              # Python pipeline that runs preprocessing, fits the model, and exports parameters
├── employee_burnout_analysis-AI 2.xlsx # Dataset containing 22,750 employee records
└── README.md                    # Project documentation

Dataset and Feature Engineering

The underlying model is trained on a comprehensive dataset of 22,750 employee records. The pipeline processes the following characteristics to compute the target burn rate:

Predictor Features

  1. Designation Level: Numeric score from 0 to 5 reflecting the hierarchical level of the employee (0 representing entry-level and 5 representing senior-level).
  2. Resource Allocation: Numeric value from 1 to 10 indicating the number of average daily working hours allocated to the employee.
  3. Mental Fatigue Score: Self-reported mental exhaustion metric ranging from 0.0 (no fatigue) to 10.0 (extreme fatigue).
  4. Gender: Encoded gender category (Female or Male).
  5. Company Type: Type of organization where the employee is working (Product-based or Service-based).
  6. WFH Setup Available: Binary flag indicating whether the employee has a designated work-from-home setup.

Data Preprocessing Pipeline

  • Categorical Encoding: Converts textual categories to binary representations using one-hot encoding.
  • Imputation: Employs a 5-nearest neighbors KNN Imputer to accurately fill missing numeric values.
  • Feature Scaling: Implements standard scaling to normalize feature distributions before fitting the linear regression algorithm.

Machine Learning Pipeline and Performance

The pipeline is written in Python using scikit-learn. The model is trained using a 70:30 train-test split, shuffling the data with a fixed random seed to guarantee reproducibility.

Evaluation Metrics

Upon training, the model achieves the following performance on the test dataset:

  • Coefficient of Determination (R2 Score): 0.897276 (explains approximately 89.73% of the target variance)
  • Mean Absolute Error (MAE): 0.049608 (on a 0.0 to 1.0 scale, translating to an average error of less than 5%)
  • Mean Squared Error (MSE): 0.004009

The training pipeline and parameters are fully automated in the export_model.py script.


Technical Architecture

This project showcases a hybrid design pattern that bridges complex python model training with low-overhead frontend execution:

  1. Training and Compilation: The Python environment is used for raw data manipulation, imputation, and model fitting. Once the optimal parameters are achieved, the StandardScaler weights (mean and standard deviation), the Linear Regression weights (coefficients and intercept), and descriptive feature metadata are serialized to model_params.json.
  2. Zero-Latency Client-Side Inference: The client application loads model_params.json asynchronously upon initialization. When a user changes the dashboard controls:
    • The inputs are collected into a raw feature vector.
    • Browser-based JavaScript scales the vector using the pre-compiled mean and standard deviation parameters: scaled_val = (val - mean) / std.
    • The scaled vector is multiplied by the model coefficients and the intercept is added to calculate the prediction: y = sum(coefficient_i * scaled_i) + intercept.
    • The final rate is bounded between 0% and 100% and visual indicators update accordingly.

Getting Started

Follow these steps to run the pipeline and run the dashboard locally.

1. Prerequisites

Ensure you have Python 3.8 or higher installed on your machine. You will need the following libraries:

pip install numpy pandas scikit-learn openpyxl

2. Retraining the Model and Exporting Parameters

If you modify the source data or want to rebuild the parameters, run:

python export_model.py

This script will output the model evaluation metrics to the console and automatically compile and overwrite app/model_params.json.

3. Running the Dashboard

Since the application loads model_params.json using the standard Fetch API, a local web server is required to bypass browser CORS policies.

Option A: Python Built-in Server (Recommended)

Navigate to the project root directory in your terminal and run:

python -m http.server 8000

Then, open your web browser and navigate to http://localhost:8000/app/.

Option B: VS Code Live Server Extension

If you use Visual Studio Code, right-click app/index.html and select Open with Live Server.


User Interface and Burnout Risk Thresholds

The dashboard classifies predicted burnout rates into four distinct action-oriented categories:

  • Low Risk (Under 25%): Indicates the employee shows minimal signs of exhaustion. Workload allocation is well-balanced.
  • Moderate Risk (25% to 49%): Mild burnout indicators detected. Regular check-ins and subtle workload adjustments are recommended.
  • High Risk (50% to 74%): High risk of burnout. Active intervention is required to evaluate resources and alleviate stress.
  • Critical Risk (75% and above): Extreme burnout risk. Immediate, urgent workplace intervention and relief measures are required.

About

Using ML models to predict the employee burnout rate.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors