Where this session sits
Seventh of eight analyst sessions, one running artifact: the retention report a8 ships. You already know what retention means (a1), you built the cohort triangle (a2) and its viz gallery (a3), you segmented who retains (a4), modeled lifetimes (a5), and scored P(alive) per customer (a6). Today adds the last modeling piece: a supervised churn model that names WHO is at risk and WHY - risk scores the capstone folds into its recommendations. Work along in the companion notebook notebooks/a7_churn.ipynb on the repo's synthetic data, where the churn generator is known, so a leak shows up as an impossible score.
The framing IS the model 10 min live
Before any algorithm, you make one decision that determines whether the model is real: pick a cutoff time t. Features may use behavior up to and including t. The label is whether the customer churned in a window strictly after t - within 30, 60, or 90 days, matching a1's forward-looking law. Any feature that peeks past the cutoff is leakage: the model aces validation because it is reading the answer key, then dies in production where the future genuinely is not available yet.
LiveSpot the leak: 8 features, 3 of them lie6 min▶
A junior analyst proposes this feature list for a 90-day ecommerce churn model with cutoff t. Three features leak. Find them before reading on - in session we vote before the reveal.
tenure_days- days from first purchase to torders_last_90d- orders in the 90 days before tdays_since_last_order- computed when the training script runs (today)support_tickets_180d- tickets opened in the 180 days before texit_survey_score- the churn survey answer, NaN for active customerspayment_failures_90d- failed charges in the 90 days before tsessions_week_after_cutoff- site visits in the 7 days after tavg_order_value- mean order value over orders before t
One frame per cutoff. Every aggregate above reads only past; the label reads only future. That physical separation - two dataframes, not one - is the cheapest leakage insurance there is.
Baseline, boost, explain ★ 12 min · everyone builds
Always fit logistic regression first: its coefficients are a sanity check (does more tenure really lower risk? do payment failures raise it?) and a floor the fancy model must beat. Then XGBoost or LightGBM as the workhorse. And because churn is imbalanced, accuracy is a lie: on 5% churn, a model that predicts "nobody churns" is 95% accurate and catches zero churners. Precision-recall is the honest lens - precision is your wasted intervention budget, recall is your missed churners.
Live★ Build-along: split by time, fit, evaluate honestly8 min▶
The beeswarm answers the stakeholder question ("what drives churn here?") once, globally. The waterfall answers the CRM question ("why is this customer flagged?") per row - that per-customer explanation is what makes a score actionable instead of spooky.
Self-studyFeature ideas that survive production4 min read▶
The features that keep working are the boring ones any pipeline can recompute at any historical cutoff:
- Tenure at the cutoff - months since first purchase or install.
- Usage trend deltas - this week's activity minus last week's, week-over-week, computed inside the feature window. A falling delta is often the earliest honest signal.
- Support tickets - count and recency before the cutoff; pair with resolution time if you have it.
- Payment failures - failed charges before the cutoff; among the strongest involuntary-churn predictors.
- Days-since-last, computed at the cutoff - the same recency that powers a6's BG/NBD, and the #1 leak when computed lazily at training time.
Rule of thumb: for every feature, ask "could the data warehouse have produced this exact value on the morning of the cutoff date?" If the answer needs the word "today", it leaks.
Prediction is not prevention 8 min live
Here is the finding that should be stapled to every churn model, from Eva Ascarza's research: the customers most likely to churn are often the least persuadable. Ranking by risk and mailing the top decile wastes budget twice - on "lost causes" no offer can save, and on "sure things" who would have stayed anyway. What moves money is targeting persuadables: customers whose behavior actually changes because you contacted them. That is uplift modeling - two models (treated vs control) or one model with a treatment flag - and it needs experiment data: intervention design is experiment territory - see learn-experimentation-with-phoebe.
LiveThe four customer types - and the one worth your budget5 min▶
Cross two counterfactuals - what they do if left alone, what they do if contacted - and every customer lands in one of four boxes:
- Sure things - stay either way. Every discount sent here is margin set on fire.
- Persuadables - churn if ignored, stay if contacted. The ONLY box where the offer causes retention. All budget goes here.
- Lost causes - churn either way. Usually the top of your risk ranking, which is exactly the trap.
- Sleeping dogs - stay if ignored, churn BECAUSE you contacted them. A renewal reminder that wakes someone who forgot they were subscribed. Do not disturb.
And the threshold question changes shape: not "which cutoff maximizes F1" but which cutoff maximizes (margin saved per rescued customer) minus (cost of offer x customers contacted). A $5 winback email tolerates low precision; a $50 discount does not. Price the threshold from the intervention economics, then read the precision-recall curve at that price.
Winback economics, priced honestly. Reactivation emails realistically win back 10-30% of lapsed customers - a real but bounded lever. The combination that works in practice: a7's risk score says who is fading, a6's P(alive) says who is still plausibly alive, and a4's value segments say who is worth an offer. Send the winback to high-value, fading-but-alive customers - not to the whole top of the risk ranking, where the lost causes live and the budget goes to die.
Try it yourself - this week ◐ 40 min total
- Build the windowed training frame on the synthetic orders data with cutoff 2011-06-01 and a 90-day label window, exactly as in Part 1.
- Deliberately add one leaky feature -
days_since_lastcomputed from the dataset's max date instead of the cutoff. Refit and watch PR-AUC jump toward perfect. Feel the lie. Then remove it and keep the honest number. - Run the SHAP beeswarm and write the top-3 churn drivers as three plain sentences a stakeholder could act on - no feature names, no log-odds. "Customers whose weekly orders are falling" beats "orders_delta_w1_w2".
- Answer in one sentence: your model's top decile has 60% churn probability - why might mailing all of them a discount still lose money?
What this session draws on
ML churn modeling is standard supervised learning; what makes it churn-specific is the windowing discipline and the intervention caveat. The working core:
Three questions before you go 🎯 ◐ 90 seconds
1 · A colleague splits the churn training frame with train_test_split(shuffle=True) and reports a stellar validation score. Why is the split itself a leak?
Churn frames are time-stamped: customers observed under the same market conditions, promotions and seasonality end up in both train and test, so the model is graded on a period it effectively trained on. Split by time - train on older cutoffs, test on a strictly later one - so validation simulates deployment.
2 · Your churn rate is 5% and a model reports 95% accuracy. What have you learned about the model?
On imbalanced classes, accuracy mostly measures the class ratio. Precision-recall is the honest lens: precision prices wasted intervention budget, recall prices missed churners, and PR-AUC should be compared against the churn rate itself (a random ranker's PR-AUC), not against 0.5.
3 · Under uplift thinking, who gets the retention offer?
Ascarza's finding: the riskiest customers are often lost causes no offer can save, and blanket saves also pay sure things who would stay anyway - while sleeping dogs churn BECAUSE you contacted them. Only persuadables convert offer spend into retained revenue, and only experiment data can identify them.