Case study · 07
Employee turnover analytics — HR retention ML
Overview
End-to-end machine learning pipeline for Portobello Tech that predicts employee attrition, surfaces drivers of turnover, and maps each employee to actionable HR risk zones — optimized for high recall so at-risk staff are caught before they resign.
Project preview

Technologies used
- Python
- pandas
- NumPy
- scikit-learn
- imbalanced-learn
- Matplotlib
- Seaborn
- Jupyter Notebook
Key features
- Seven-step notebook pipeline: data quality, EDA, clustering, SMOTE, training, evaluation, and retention playbooks
- K-Means segmentation of leavers into burnout, disengagement, and external-opportunity profiles
- Stratified train/test split with SMOTE applied only on training data to avoid leakage
- Three-model comparison (Logistic Regression, Random Forest, Gradient Boosting) with 5-fold CV
- Risk-zone scoring (Safe / Low / Medium / High) with tailored retention strategies per band
- 11,991 employee records after deduplication; ~16.6% baseline turnover rate
Challenges solved
- Severe class imbalance (~16.6% leavers) without leaking synthetic samples into the test set
- Choosing recall over precision — false negatives cost far more than false alarms in HR retention
- Translating model outputs into interpretable risk zones HR teams can act on immediately
- Separating distinct leaver personas so retention tactics are not one-size-fits-all
Architecture & engineering highlights
Notebook-driven workflow: CSV ingest → EDA and clustering insights → encoded features with SMOTE on train only → ensemble classifiers → Gradient Boosting selected for production scoring → probability thresholds mapped to four HR risk zones.
Engineering highlights
Recall-first selection
Gradient Boosting chosen for 91.7% recall on leavers and 0.979 AUC — prioritizing catching at-risk employees over minimizing false alarms.
Actionable risk zones
Turnover probability buckets (Safe, Low, Medium, High) with specific HR interventions from check-ins to urgent retention packages.
Driver clarity
EDA tied satisfaction, workload extremes, and tenure to attrition — satisfaction level showed the strongest negative correlation with leaving (−0.39).
Screenshots
Future improvements
- Hyperparameter tuning with GridSearchCV or Optuna
- SHAP-based feature importance for explainability with HR stakeholders
- REST API or Streamlit dashboard for real-time turnover risk scoring
- A/B testing retention interventions and measuring impact over time








