A data-driven HR analytics solution combining EDA, Random Forest ML, and an interactive Streamlit dashboard to help organizations identify and reduce employee attrition.
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.
| Value | Meaning |
|---|---|
| Yes (1) | Employee left the company |
| No (0) | Employee stayed |
| 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
๐ค 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
- Distribution of Age, Monthly Income, and Attrition rate
- Monthly Income vs Attrition
- Years at Company vs Attrition
- Job Satisfaction vs Attrition
- Over Time vs Attrition
- Correlation heatmap across all numerical features
| 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 |
- Younger & less experienced employees
- Lower salary bracket
- Working overtime with low job satisfaction
| 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
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
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
git clone https://github.com/Shrihariniselvakumar/HR-Employee-Attrition-Analysis-Prediction.git
cd HR-Employee-Attrition-Analysis-Predictionpip install -r requirements.txtstreamlit run app.pyHR-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
- 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
This project is open source and available under the MIT License.