Skip to content

Shrihariniselvakumar/HR-Employee-Attrition-Analysis-Prediction

Repository files navigation

๐Ÿ‘ฅ HR Employee Attrition Analysis & Prediction

A data-driven HR analytics solution combining EDA, Random Forest ML, and an interactive Streamlit dashboard to help organizations identify and reduce employee attrition.

Python Streamlit Scikit-learn


๐Ÿ“Œ Project Overview

This project analyzes employee attrition using HR data and builds insights into why employees leave an organization. It combines:

  • ๐Ÿ“Š Exploratory Data Analysis (EDA) โ€” uncovering patterns across 31 features
  • ๐Ÿค– Machine Learning โ€” Random Forest classifier for attrition prediction
  • ๐Ÿ“ˆ Interactive Streamlit Dashboard โ€” real-time KPIs, prediction, and visualizations

The goal is to help HR teams make data-driven decisions to improve employee retention.


๐ŸŽฏ Target Variable

Value Meaning
Yes (1) Employee left the company
No (0) Employee stayed

๐Ÿ“Š Dataset Summary

Property Detail
Total Records 1,470 employees
Total Features 31 (after cleaning)
Missing Values None
Data Type Structured HR Dataset

Removed columns:

  • Constant columns โ€” Employee Count, Standard Hours
  • Irrelevant derived features โ€” CF columns

๐Ÿงพ Feature Categories

๐Ÿ‘ค Demographic Features
  • Age, Gender, Marital Status, Education, Education Field
๐Ÿ’ผ Job-Related Features
  • Department, Job Role, Job Level, Business Travel, Over Time
๐Ÿ’ฐ Compensation Features
  • Monthly Income, Daily Rate, Hourly Rate, Monthly Rate, Percent Salary Hike, Stock Option Level
๐Ÿ˜Š Performance & Satisfaction
  • Job Satisfaction, Environment Satisfaction, Relationship Satisfaction, Work Life Balance, Job Involvement, Performance Rating, Training Times Last Year
๐Ÿ“… Experience & Tenure
  • Total Working Years, Years At Company, Years In Current Role, Years Since Last Promotion, Years With Current Manager, Num Companies Worked, Distance From Home

๐Ÿ“ˆ Exploratory Data Analysis (EDA)

โœ” Univariate Analysis

  • Distribution of Age, Monthly Income, and Attrition rate

โœ” Bivariate Analysis

  • Monthly Income vs Attrition
  • Years at Company vs Attrition
  • Job Satisfaction vs Attrition
  • Over Time vs Attrition

โœ” Multivariate Analysis

  • Correlation heatmap across all numerical features

๐Ÿ” Key Insights

Insight Finding
๐Ÿ’ธ Income Employees with lower income are more likely to leave
โณ Tenure Employees with shorter tenure show higher attrition
๐Ÿ˜“ Overtime Overtime significantly increases attrition risk
๐Ÿ˜ Satisfaction Low job satisfaction strongly correlates with leaving
๐Ÿ“Š Salary Strongly linked with experience and job level
๐Ÿ” Tenure features Highly correlated with each other

๐ŸŽฏ High-Risk Employee Profile

  • Younger & less experienced employees
  • Lower salary bracket
  • Working overtime with low job satisfaction

๐Ÿค– Machine Learning Model

Property Detail
Algorithm Random Forest Classifier
Accuracy 85%+
Preprocessing StandardScaler for feature scaling

Input Features used for prediction:

  • Age
  • Monthly Income
  • Years at Company
  • Job Satisfaction
  • Over Time

๐Ÿ–ฅ๏ธ Streamlit Dashboard

The interactive dashboard includes:

  • ๐Ÿ“Š KPI Metrics โ€” Overall attrition rate, average salary, average tenure
  • ๐Ÿ” Data Exploration โ€” Filter and explore employee data interactively
  • ๐Ÿค– Attrition Prediction โ€” Enter employee details and get instant risk prediction
  • ๐Ÿ“ˆ Feature Importance โ€” Visualize which factors drive attrition the most

๐Ÿ“ธ Screenshots

Coming soon โ€” upload screenshots to the screenshots/ folder and update the paths below

screenshots/
โ”œโ”€โ”€ kpi_dashboard.png
โ”œโ”€โ”€ eda_charts.png
โ”œโ”€โ”€ prediction_panel.png
โ””โ”€โ”€ feature_importance.png

๐Ÿ› ๏ธ Tech Stack

Python Pandas NumPy Scikit-learn Matplotlib Seaborn Streamlit


๐Ÿš€ Getting Started

1. Clone the repository

git clone https://github.com/Shrihariniselvakumar/HR-Employee-Attrition-Analysis-Prediction.git
cd HR-Employee-Attrition-Analysis-Prediction

2. Install dependencies

pip install -r requirements.txt

3. Run the app

streamlit run app.py

๐Ÿ“ Project Structure

HR-Employee-Attrition-Analysis-Prediction/
โ”‚
โ”œโ”€โ”€ app.py                      # Streamlit dashboard
โ”œโ”€โ”€ model/
โ”‚   โ”œโ”€โ”€ train_model.py          # Random Forest training script
โ”‚   โ””โ”€โ”€ attrition_model.pkl     # Saved model
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ hr_dataset.csv          # IBM HR Analytics dataset (1470 records)
โ”œโ”€โ”€ notebooks/
โ”‚   โ””โ”€โ”€ EDA.ipynb               # Full EDA notebook
โ”œโ”€โ”€ screenshots/                # App screenshots
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

๐Ÿ”ฎ Future Improvements

  • Add SHAP explainability for individual predictions
  • Retention strategy recommendations per high-risk employee
  • Connect to live HRMS data via API
  • Deploy on Streamlit Cloud
  • Email alerts for HR managers on high-risk employees

๐Ÿ‘ฉโ€๐Ÿ’ป Author

Shri Harini Selvakumar
LinkedIn GitHub


๐Ÿ“„ License

This project is open source and available under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors