Applied Data Science IDCamp Expert · HR Analytics · XGBoost · Docker

Prevent employee turnover
before it happens.

XGBoost early-warning system for a multinational with 16.92% annual attrition. 86.11% recall, 81.93% ROC-AUC, 5-tab Metabase dashboard, Docker + PostgreSQL deployment.

Model XGBoost · 86.11% Recall · AUC 81.93% Infra Docker · PostgreSQL · Metabase · Streamlit Dataset 1,470 employees · 72 features · IBM HR Analytics Level IDCamp Expert 2025
86.11%
Recall
catches 86% of leavers
81.93%
ROC-AUC
XGBoost selected
Overtime risk
31.92% vs 10.79%
5
Dashboard tabs
Docker deployed
01 · Business Problem

Attrition above 10% is a management warning sign. Theirs was 16.92%.

No structured early-warning existed. Attrition was discovered only after an employee resigned.

Replacing one employee costs 50–200% of their annual salary. At 179 per year, the financial exposure is substantial — and most of it is preventable with early identification.

The dataset covers 72 features across four domains that predict departure:

  • Work conditions — Overtime, business travel, distance from home
  • Compensation — Monthly income, salary hike, stock options
  • Satisfaction — Job satisfaction, environment score, work-life balance
  • Career trajectory — Tenure, years since promotion, training frequency
XGBoostSMOTEHR Analytics MetabasePostgreSQLDocker
02 · Solution Architecture

From raw HR data to operational HR intelligence.

The pipeline goes end-to-end: data cleaning, feature engineering, SMOTE class balancing, XGBoost training, batch prediction, PostgreSQL storage, and Metabase visualisation — all containerised with Docker.

Key engineering decisions

  • SMOTE on train only — Synthetic minority samples are created before train/test split to prevent data leakage into evaluation metrics
  • Custom sklearn transformerHRFeatureEngineer bundles age-grouping, binary encoding, ordinal encoding, and one-hot encoding into a single reusable pipeline step
  • Stratified K-Fold — 5-fold evaluation preserves class ratio across folds; GridSearchCV uses 4-fold for hyperparameter tuning
  • Docker Compose — single docker compose up starts both PostgreSQL and Metabase containers; no manual database setup
  • SQLAlchemy batch write — prediction results written directly to PostgreSQL, automatically populating the Metabase Early Warning tab
03 · Model Selection

Recall beats accuracy when missing a leaver costs more than a false alarm.

Baseline

Logistic Regression

74%
Accuracy
72%
Recall
80%
AUC
✗ Misses too many leavers
Selected

XGBoost

60%
Accuracy
86%
Recall
82%
AUC
✓ Best business choice
Why False Negatives Are Expensive
False Negative
Employee resigns
No intervention
Replacement cost

XGBoost has lower raw accuracy because it aggressively catches attritors, flagging some who stay. But in HR, a false positive costs a counselling conversation. A false negative costs an employee. The asymmetry clearly favors recall.

04 · Key Risk Factors

Overtime, first-year tenure, young age. Three compounding multipliers.

🥇 Top Risk Factor
Tenure ≤ 1 year
34.59%
Attrition rate
~4× vs 5+ year peers
🥈 Risk Factor
Age 18–25
38.04%
Attrition rate
~4× vs 46+ cohort
🥉 Risk Factor
Sales Representative
43.10%
Attrition rate
Highest attrition role
4 Risk Factor
Overtime Required
31.92%
Attrition rate
~3× vs no overtime
5 Risk Factor
Low Salary (Q1)
29.06%
Attrition rate
~3× vs top quartile
6 Risk Factor
Poor Work-Life Balance
32.14%
Attrition rate
~3× vs score 4

Feature Importance

"The first year is the most vulnerable — 34.59% of employees with ≤1 year tenure leave. Pair that with overtime or low salary, and you've identified employees who almost certainly won't see year 2."
05 · Business Impact

From reactive to proactive. 86% of leavers identified before they resign.

Without Model
Employee considers leaving
No signal
Manager surprised
Employee resigns
Replacement costs begin
With Model
Employee shows risk signals
Model flags high risk
HR interview
Retention program
Employee stays
86%
Attritors detected before resignation

Only 5 false negatives

On the test set, XGBoost missed only 5 actual attritors. In HR intervention terms, this means 5 employees who would have left without any outreach — out of 36 total test-set attritors. That's a 86% catch rate at deployment scale.

Controllable factor: Overtime

Overtime is the strongest single driver and the most actionable one. Eliminating mandatory overtime for high-risk employees is a direct policy lever. A what-if simulation (planned) will quantify this impact per department.

06 · Prediction Pipeline

Batch prediction → PostgreSQL → Dashboard. HR sees results in the browser.

Input

  • CSV of employee records with all 72 feature columns
  • HRFeatureEngineer transformer: age grouping, binary/ordinal/one-hot encoding in one pipeline step
  • Same feature engineering as training — no manual preprocessing per-run

Output

  • Attrition probability score (0–100%) per employee
  • Binary prediction: high-risk or not
  • Written to PostgreSQL via SQLAlchemy — Metabase Early Warning tab auto-updates

Infrastructure: docker compose up starts PostgreSQL + Metabase. The entire analytics environment spins up in one command.

07 · Dashboard Showcase

5-tab Metabase dashboard — from executive KPIs to individual risk scores.

Built on Docker + PostgreSQL. HR teams access everything through the browser — no Jupyter notebooks, no Python scripts.

Executive Summary dashboard — total employees, attrition rate, department and role breakdown
① Executive Summary KPIs · Attrition rate · Department & role breakdown
Compensation and Workload tab — overtime vs attrition, business travel impact, salary quartile analysis
② Compensation & Workload Overtime · salary quartiles · travel impact
Satisfaction and Engagement tab — job satisfaction scores, work-life balance vs attrition
③ Satisfaction & Engagement Self-reported scores vs attrition
Demographics and Career tab — attrition by age group, tenure cohort, years since last promotion
④ Demographics & Career Age groups · tenure bands · promotion recency
Early Warning System tab — ML predictions per employee, risk tier distribution, top 50 high-risk employees
⑤ Early Warning System Risk tiers · top high-risk employees · department filter
08 · Technical Stack

From model to production infrastructure.

ML
XGBoostensemble model
scikit-learnpipeline + eval
SMOTEimbalancedlearn
GridSearchCVtuning
Data
pandasEDA + transform
numpynumerical ops
matplotlibvisualisation
seabornEDA plots
Backend
Python 3.10batch predict
SQLAlchemyDB connector
Streamlitlive demo UI
Database
PostgreSQLprediction storage
MetabaseHR dashboard
Infra
Dockercontainers
Docker Composeorchestration
GitHubsource control
09 · Learning Journey

Expert level, first submission. Rejected once, then ★4.

This was the capstone of IDCamp 2025 Expert — Belajar Penerapan Data Science (110 hours, rated 4.89). It went through two rounds of reviewer feedback before reaching ★4.

Reviewer feedback

What I carry from this

Reproducibility = feature

A model that can't be reproduced by the reviewer doesn't exist. Infrastructure completeness — setup scripts, requirements, README steps — is as important as model performance.

Business metric over accuracy

Choosing XGBoost despite lower accuracy taught me that the right metric depends on the cost of each error type, not the most intuitive number on the leaderboard.

Specific recommendations

General recommendations feel safe but land flat. Every recommendation needs a segment (who), a number (how much), and a step (what to do) to be actionable.

Deploy first, optimise later

Getting the Metabase dashboard running inside Docker and accessible to HR was the moment this became a product, not just a notebook. The engineering matters.

10 · Future Roadmap

From prediction to explanation and simulation.

Current
Batch Prediction
CSV → XGBoost → PostgreSQL → Metabase. 86.11% recall. 5-tab dashboard. Docker deployed.
Next
SHAP Explainability
Per-employee explanation: "high risk because overtime=Yes, tenure=0.8yr, salary=Q1." Makes predictions actionable at individual level.
Future
What-If Simulation
Streamlit: "If overtime is removed for this department, how does attrition change?" Turns dashboard from passive report to decision tool.
Vision
Production API
REST endpoint for HR system integration. Real-time prediction on new hires. Segment-based intervention recommendations with measured ROI.
Try it · See the code

Live Streamlit demo + full source on GitHub.

Try the prediction interface or explore the XGBoost pipeline, Metabase dashboard setup, and Docker infrastructure. Full source including setup_database.py and requirements.txt.