Skip to content

About

End-to-end HR analytics pipeline using Python and SQL to identify key employee turnover drivers, evaluate flight risk, and calculate financial cost of turnover.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Employee Attrition & Turnover Cost Analysis

An analysis of employee attrition patterns, flight-risk drivers, and cost of turnover using Python (Pandas, Matplotlib, Seaborn) and SQL (MySQL & SQLite).

Created by Chetan Rupchandani


Business Problem & Context

Employee turnover is one of the most significant hidden costs for any business. Industry research shows that replacing an employee costs roughly 50% of their annual salary due to recruitment, onboarding, training, and lost productivity.

Using a dataset of 1,470 employees (IBM HR Analytics dataset schema), this project answers four core questions:

  1. Which departments and job roles lose the most people?
  2. What are the key drivers of attrition? (e.g., overtime, pay variance)
  3. What is the total financial cost of turnover to the company?
  4. Where should HR focus first to get the highest ROI on retention?

Key Findings

  • Overall Attrition Rate: 16.1% (237 out of 1,470 employees left).
  • Overtime is the #1 Driver: Employees working overtime leave at 30.5%, compared to 10.4% for those who don't — nearly 3x higher flight risk.
  • Riskiest Department: Sales has the highest department attrition rate at 20.6%.
  • Riskiest Role: Sales Representative at 39.8% attrition.
  • Pay Gap: Employees who left earned 29.9% less on average ($4,787/month vs. $6,833/month for stayers).
  • Estimated Annual Turnover Cost: ~$6.81 Million, split mainly between Research & Development ($3.28M) and Sales ($3.26M).

Visual Dashboard

The analysis generates a 4-panel executive dashboard saved in outputs_charts/attrition_dashboard.png:

Attrition Dashboard


Data Pipeline & Project Architecture

data/employee_attrition.csv  ──>  SQLite / MySQL Database  ──>  SQL Queries (sql/queries.sql)
                             └──>  Pandas Analysis (src/analysis.py)  ──>  Cost Calculation + Dashboard

Actionable Recommendations & Expected Savings

  1. Target Sales First: Sales loses the highest percentage of staff (20.6%), costing $3.26M annually.
  2. Address Overtime Burnout: Since overtime triples turnover risk, rebalancing workload or adjusting shift caps will significantly improve retention.
  3. Financial ROI: Reducing Sales attrition by just 10% would save the company approximately $326,147 per year.

Project Structure

attrition_project/
├── data/
│   ├── employee_attrition.csv      # Primary dataset (1,470 records)
│   └── make_sample_data.py         # Synthetic data generator script
├── sql/
│   └── queries.sql                 # Business questions answered in SQL
├── src/
│   ├── analysis.py                 # Main Pandas analysis & chart generator
│   ├── load_to_mysql.py            # MySQL data loader script
│   └── run_sql_demo.py             # SQLite query runner (no MySQL required)
├── outputs_charts/
│   ├── attrition_dashboard.png     # 4-panel executive chart
│   └── attrition_by_department.png # Standalone department plot
├── .gitignore
├── LICENSE                         # MIT License
├── README.md                       # Project documentation
├── requirements.txt                # Python dependencies
└── RESUME_BULLETS.md               # Resume bullet points & interview highlights

How to Run

1. Install Dependencies

python3 -m pip install -r requirements.txt

2. Run the SQL Queries (SQLite - Instant, No Setup Needed)

python3 src/run_sql_demo.py

3. Run the Python Analysis & Generate Dashboard

python3 src/analysis.py

4. (Optional) Run with MySQL

export MYSQL_PASSWORD="your_password"
python3 src/load_to_mysql.py

License

Distributed under the MIT License. See LICENSE for details.

About

End-to-end HR analytics pipeline using Python and SQL to identify key employee turnover drivers, evaluate flight risk, and calculate financial cost of turnover.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages