Predicting Employee Churn for HR
The goal of this project was divided into 2 parts:
- To explore the given data in order to determine the circumstances that are likely to cause an employee to leave the company.
- To create a Machine Learning Model to predict employee churn.
This project utilized data collected by the HR department. Three classifiers were compared — Decision Tree, Random Forest, and XGBoost — and the Random Forest champion delivered the following test-set performance:
| Metric | Test Score |
|---|---|
| Accuracy | 0.9797 |
| Precision | 0.9797 |
| Recall | 0.8994 |
| F1 | 0.9375 |
| AUC | 0.9475 |
(Validation-set scores were marginally higher at ~0.9823 accuracy / 0.9823 precision; test set is the authoritative number reported here.) Based on the model, satisfaction level, average monthly hours, and last evaluation score were the three most influential features in determining whether or not an employee will leave.
Predicting which employees are likely to quit can significantly benefit the company by reducing the time and costs associated with the recruitment process. Early identification of potential turnover enables HR to implement targeted strategies to improve employee retention, ensuring the organization can maintain productivity and focus on critical projects.
The HR Analytics Dataset came from Kaggle. The data consisted of approximately 15,000 employees and 10 features. The features included information on employee satisfaction level, their last evaluation score, the number of projects they contribute to, the average hours worked per month, as well as other features.
- Removed 1,008 duplicate rows (15,000 → 11,991 employees).
- Renamed misspelled
average_montly_hours→average_monthly_hours, andtime_spend_company→tenure. All columns standardized to lowercase snake_case. - Outliers in
tenure > 5years (824 rows) were detected via boxplot but retained, since they represent a meaningful long-tenure retention cohort rather than data errors. - Class balance: 16.6% churned, 83.4% retained. Imbalanced, but no SMOTE or class-weight applied — the Random Forest handled it via implicit subsampling and still delivered 0.95 AUC.
- Engineered
overworkedbinary flag (1 ifaverage_monthly_hours > 175, else 0). Threshold motivated by a standard 50-hour work week. This derived feature ranks among the top drivers of churn. salaryordinal-encoded (low=0, medium=1, high=2).departmentone-hot encoded into 10 binary columns.
- Three-way split: ~50% train / ~19% validation / ~25% test,
random_state=42. - 5-fold GridSearchCV refit on ROC-AUC.
- Random Forest search space:
n_estimators ∈ [50, 100],max_depth ∈ [10, 50],max_features ∈ [sqrt, log],min_samples_split ∈ [0.001, 0.01]. - Best Random Forest params:
n_estimators=50,max_depth=10,max_features='sqrt',min_samples_split=0.001.
The Random Forest champion was selected by F1 on the validation set. Full comparison:
| Model | F1 | Accuracy | Precision | Recall | AUC |
|---|---|---|---|---|---|
| Decision Tree | 0.9091 | 0.9707 | 0.8943 | 0.9244 | 0.9519 |
| Random Forest (champion) | 0.9454 | 0.9823 | 0.9822 | 0.9084 | 0.9801 |
| XGBoost | 0.9356 | 0.9789 | 0.9647 | 0.9085 | 0.9800 |
The below plot shows that satisfaction_level, average_monthly_hours, and last_evaluation were the Top 3 most important factors in determining employee turnover. 
The most actionable patterns came from the EDA, not the model:
- 100% of employees with 7 concurrent projects left the company — a hard ceiling on workload before churn becomes certain.
- 3–4 projects is the retention sweet spot. More than 4 projects correlates with > 250 hours/month worked.
- Bimodal evaluation pattern: both very low (~0.5) and very high (~0.9) performers leave at elevated rates. The high-performer cluster is the more surprising — overworked top performers leaving is a workload problem, not an engagement problem.
- Tenure cluster: high-performing employees with ~5 years of tenure are leaving despite high satisfaction. This is the most actionable retention opportunity — these are people the company has invested in, who haven't been promoted.
- 25.2% of churners had satisfaction between 0.09 and 0.11 — a deeply dissatisfied cluster that needs a different intervention than the burned-out high-performer cluster.
- Highest-turnover departments: Sales, Technical, and Support, across all salary bands.
- Cap projects at 3–4 per employee. More than 4 leads to overwork.
- Promote at the 4-year tenure mark. Even satisfied employees leave without progression.
- Reward long hours or remove the expectation — the current state (expecting overtime without rewarding it) is the worst of both.
- Treat the two churn clusters separately: dissatisfied employees need engagement fixes; overworked top performers need workload + progression fixes.
Python · Pandas · NumPy · scikit-learn · XGBoost · Matplotlib · Seaborn · Jupyter
- Synthetic-feeling Kaggle dataset from a single fictional company — patterns may not transfer cleanly to real organizations without re-validation.
- Snapshot, not time-series — no longitudinal tracking of how satisfaction or workload trended in the months before churn.
- Class imbalance unaddressed (16.6% positive class). Random Forest handled it, but a stratified split or SMOTE comparison would strengthen the analysis.
- Correlational, not causal — overwork predicts churn, but observational data alone can't prove overwork causes churn.
- Missing organizational context — no compensation amounts, manager-quality signals, training data, or growth-track features.
The predictive models developed in this project demonstrated the potential to significantly enhance HR decision-making by identifying employees at risk of leaving with high accuracy and precision. The Random Forest model, achieving 0.95 AUC and 90% recall on the held-out test set, proved most effective in determining the key factors influencing employee turnover — satisfaction level, average monthly hours, and last evaluation score. These insights can help HR teams proactively address retention challenges, optimize workforce strategies, and foster a more stable and engaged workplace. Future efforts could focus on incorporating additional data sources (compensation, manager quality, longitudinal trends) and refining the model to address unique organizational contexts.
