Churn Prediction Model

At Heineken Mexico, I developed an ML model that predicts the probability customers will stop puchasing (churn). Separately, here I highlight another ML model, developed during a technical assessment, that predicts when employees might quit.

Python scikit-learn XGBoost FastAPI PostgreSQL Docker
Churn Prediction Model

Description

This is an ML model that predicts the probability employees will quit, for a logistic company with 80,000 active employees. The model identifies employees at risk of leaving 30 days ahead of time, allowing proactive retention strategies.

Problem

The company had a monthly churn rate of 3.2% and no reliable way to anticipate which customers were at risk. Retention campaigns were reactive and expensive.

Solution

End-to-end pipeline including:

  1. Feature Engineering: 45 variables derived from call history, payments, and support interactions
  2. Modeling: XGBoost optimized with Optuna (200 trials)
  3. Evaluation: time-based cross-validation to prevent data leakage
  4. Serving: REST API with daily score updates
  5. Integration: CRM webhooks for automated alerts

Business Results

  • Monthly churn reduction from 3.2% β†’ 2.1% within 6 months
  • Estimated ROI: $180K USD in customer retention during the first year
  • Captured 78% of actual churners within the top 20% highest-risk scores

Technical Metrics

Metric Value
AUC-ROC 0.91
Precision @20% 0.61
Recall @20% 0.78
API p95 Latency 35ms

Technical Stack

  • ML: scikit-learn, XGBoost, Optuna, SHAP
  • Data: Pandas, NumPy, PostgreSQL, SQLAlchemy
  • API: FastAPI, Pydantic
  • Infrastructure: Docker, Cloud Run, Cloud Scheduler