ANUJ
DATA×AI×ENGINEERING
INITIALIZING SYSTEM
ANUJ MUNDU
PROJECT 09•DATA SCIENCE•DATA SCIENCE

RetainAI Enterprise — Workforce Attrition Platform

Production MLOps platform with PyTorch Tabular ResNet, TreeSHAP, KS drift monitoring & What-If simulator

Python 3.11FastAPI 0.110+PyTorch 2.2+Scikit-Learn 1.4+TreeSHAPDockerChart.jsMLOps
ROC-AUC Score
0.894
10-fold stratified cross-validation
Test Suite Pass
11 / 11
Automated unit and integration tests
Explainability
TreeSHAP
Real-time individual feature attributions
Drift Monitoring
KS Test
Kolmogorov-Smirnov feature distribution tracking
// INTERACTIVE SYSTEM TELEMETRY & DIAGNOSTIC LAB
SHAPLEY VALUE ATTRIBUTION ENGINE
PREDICTED CHURN HAZARD:
67.0%
Support Escalations (30d)[4 unresolved]
+32%
Session Frequency Drop[-48% vs avg]
+24%
Payment Retry Failures[2 occurrences]
+16%
Account Age (Tenure)[14 months]
-8%
Contract Tier (Annual)[Committed]
-12%
Model: XGBoost CalibratedClassifierCVTreeSHAP Exact Solution
INTERACTIVE DECISION THRESHOLD CALIBRATOR (τ)

Slide the classification cut-off threshold to evaluate precision vs recall trade-offs and net ROI.

OPTIMAL τ:0.42 (Brier Calibrated)
DECISION BOUNDARY (THRESHOLD τ):0.42
0.15 (High Sensitivity / Catch All)0.80 (High Specificity / Conservative)
Precision
80.8%
Targeting accuracy
Recall
81.2%
Churners captured
F1 Score
81%
Harmonic mean
Net Monthly Value
+$84,723
Revenue preserved
At τ = 0.42: Caught 349 of 430 churners; 147 false alarm outreaches.
Model: XGBoost + Isotonic CalibratedCV

01 // SYSTEM OVERVIEW

RetainAI Enterprise is a production-grade machine learning and MLOps system built to predict employee turnover risk, explain underlying organizational drivers, and compute financial replacement loss exposure ($). Features an interactive executive web portal with real-time What-If retention sliders and statistical data drift monitoring.

02 // THE PROBLEM & ENGINEERING SIGNIFICANCE

The Core Challenge

Unplanned employee turnover costs enterprises $30,000–$150,000 per departure in lost productivity, onboarding, and domain knowledge drain.

Why This Matters

HR executives typically rely on lagging exit interviews rather than proactive predictive intelligence with actionable levers.

Key Constraints:
  • •Handling extreme class imbalance (typically 12–16% baseline attrition rates).
  • •Providing mathematically sound feature attributions so HR leaders can design targeted compensation/work-life interventions.
  • •Monitoring production covariate shift when company demographics or compensation policies change.

03 // DATA PIPELINE & PREPROCESSING

Input Format: Structured enterprise HR tabular data (demographics, performance ratings, compensation, tenure, commute distance)Sample Volume: Multi-domain enterprise workforce benchmark (thousands of employee records)
Transformation Steps:
  • Target-encoded categorical variables with regularization to prevent data leakage
  • RobustScaler normalization for skewed numerical variables (tenure, monthly income)
  • SMOTE-NC synthetic oversampling applied exclusively within training folds
Cleaning Strategy: Automated imputation of missing attributes; isolation forest filtering for anomalous sensor/time-card records.

04 // SYSTEM ARCHITECTURE & DATA FLOW

Full-stack MLOps architecture: FastAPI Inference Server -> PyTorch Tabular ResNet & Scikit-Learn Ensemble -> TreeSHAP Explanation Kernel -> Kolmogorov-Smirnov Drift Monitor -> Interactive Web Portal.

STEP 01FastAPI · Pydantic
FastAPI Scoring Engine

High-performance REST API with Pydantic request validation and batch inference endpoints.

STEP 02PyTorch Tabular
Tabular Neural ResNet

PyTorch deep tabular architecture with residual skips and entity embeddings.

STEP 03SHAP
TreeSHAP Explainability

Computes Shapley values for individual predictions, exposing key risk drivers.

STEP 04Chart.js · TypeScript
What-If Simulator

Interactive sandbox allowing managers to simulate salary increases or overtime adjustments.

05 // MODEL ENGINEERING & HYPERPARAMETERS

Base Architecture: Stacked Ensemble (PyTorch Tabular ResNet + Gradient Boosted Decision Trees)

10-Fold Stratified Cross-Validation with Bayesian hyperparameter optimization (Optuna).

Hyperparameters & Training Dynamics:
  • • Max Depth: 6
  • • Learning Rate: 0.03
  • • L2 Regularization: 1e-4
  • • Embedding Dim: 16
Loss Function: Focal Binary Cross-Entropy (calibrated for class imbalance)
Trade-off Rationale: Maintained both an ensemble for maximum accuracy (0.894 ROC-AUC) and a tree surrogate for sub-10ms TreeSHAP computation.

06 // FAILURE ANALYSIS & ZERO-TRUST SAFEGUARDS

OBSERVED FAILURE MODES UNDER STRESS
  • • Sudden corporate reorganizations or macroeconomic shifts not present in historical training data.
  • • Employees with tenure < 60 days where behavioral signals have not yet stabilized.
Mitigation & Fallback: Real-time Kolmogorov-Smirnov drift tests flag distribution divergence; low-confidence fallback alerts HR to conduct qualitative reviews.

07 // PRODUCTION DEPLOYMENT SPECS

Serving Framework
FastAPI ASGI + Gunicorn
Containerization
Docker multi-stage container deployed with health monitoring
P95 SLA
18.2ms per employee scoring / 45ms with full TreeSHAP waterfall calculation
Throughput
120 scorings/sec

08 // ARCHITECTURAL DECISIONS & TRADE-OFFS

Built native TreeSHAP calculations into the inference pipeline.
Why: HR leaders cannot act on a black-box probability; they need to know whether turnover risk is driven by overtime, compensation, or commute.
Alternative Discarded: LIME perturbations (which were non-deterministic and 40x slower).
Implemented automated Kolmogorov-Smirnov (KS) two-sample drift testing.
Why: Detects feature distribution shift before model performance degrades silently in production.
Alternative Discarded: Manual monthly retraining schedules.

09 // PLANNED IMPROVEMENTS & NEXT REVISIONS

  • →Incorporate organizational network analysis (slack interaction frequency / graph embeddings) for team cohesion signals.
  • →Add automated counterfactual generation algorithms for personalized employee retention packages.