Designing a Churn Risk System: Classification vs. Survival
Machine LearningModel answerLast updated
Design an end-to-end churn prediction system for a subscription business, choosing between windowed binary classifiers and time-to-event models, avoiding leakage, and turning scores into daily actions.
Context
You are a data scientist at a subscription software company. The customer success (CS) team has limited outreach capacity and wants a daily ranked list of accounts most likely to cancel, plus guidance on the drivers behind each score. The available longitudinal table includes, per customer: monthly_billing_amount, support_ticket_volume, days_since_last_login, subscription_start_date, and a binary churn_status flag.
What to deliver
- Framing the task. Compare a binary classifier (e.g., logistic regression, random forest) that predicts "churn within the next H days" against a survival model (Kaplan–Meier, Cox proportional hazards). Discuss data handling and business usefulness for each.
- Features and leakage. Name realistic leakage traps in this dataset and explain how features and labels must be computed relative to a snapshot date. Address how customers who haven't churned yet are handled during training.
- Evaluation. Given monthly churn of roughly 2–5%, say which metrics you would trust for the classifier and how you would evaluate a survival model such as Cox (e.g., C-index), and why.
- Deployment. Describe how to turn probabilities or risk scores into a concrete daily worklist for CS, including prioritization logic and how you would validate business impact.
Constraints
- The data is longitudinal (multiple observations per customer over time).
- New customers lack history; long-tenured customers behave differently — account for both.
- Discuss the tension between interpretability (coefficients, hazard ratios) and predictive power.
Hints
Hint 1
Frame churn as a time-to-event with censoring, not just a yes/no label — note how a windowed classifier discards customers without full follow-up.
Hint 2
Every feature must be computed as of a snapshot date using only data before it; lifetime aggregates and post-cancellation signals are classic leaks.
Hint 3
With 2–5% positives, accuracy is useless — anchor evaluation on precision@k where k equals the CS team's daily capacity.
Hint 4
Convert any score (Cox survival curve or calibrated probability) into the same 30-day churn probability so models and actions are comparable.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Framing
Binary classifier. Reformulate as: at a snapshot date t, will this account churn in (t, t+H], with H typically 30 days? Advantages: mature tooling, direct probability output, tree models capture nonlinear effects like a login-recency cliff. Disadvantages: it ignores timing — a customer who cancels on day 31 is labeled negative — and every change of H requires relabeling and retraining. Worse, accounts whose observation window ends before t+H have unknown labels and must be dropped, which wastes data and skews training toward older cohorts.
Survival model. Model the duration T from subscription start to cancellation with event indicator δ. Kaplan–Meier is non-parametric and covariate-free: excellent for descriptive retention curves by segment and as a baseline, but it cannot score individuals. Cox proportional hazards posits h(t|x) = h₀(t)·exp(xᵀβ). It uses censored customers natively (duration = min(churn time, censor time), δ = 1 only if churn observed), yields a full survival curve S(t|x) so any horizon is readable without retraining, and exp(β) gives interpretable hazard ratios. The baseline hazard h₀(t) also absorbs tenure effects such as elevated early-life risk. Costs: the proportional-hazards assumption must be checked (Schoenfeld residuals), time-varying covariates like login recency require start-stop (counting-process) data, and nonlinear survival tooling (random survival forests, gradient-boosted Cox) is less mature.
A practical middle ground worth naming: the discrete-time hazard model. Expand data to one row per customer-month and fit any classifier to P(churn in month k | survived to k, x_k). It handles censoring and time-varying features correctly while letting you use familiar models. For longitudinal data like this, many strong answers land here.
Interpretability vs. performance. Logistic or Cox models support statements like "each extra support ticket in the last 30 days multiplies the hazard by 1.12" — CS can act on that. Gradient-boosted models usually rank better by exploiting interactions (high bill × rising tickets) but need SHAP to explain. A common pattern: boosted model for ranking, sparse linear/Cox model for the narrative; ship the opaque model only if lift at the operating threshold clearly justifies it.
2. Features, leakage, censoring
Build everything as point-in-time snapshots: features from [t−k, t), labels from (t, t+H], joined as-of on event logs rather than reading current table state.
Leakage traps to call out:
days_since_last_logincomputed at extraction time: for churned accounts this keeps growing post-cancellation, making it a near-perfect but useless predictor. Compute as of t.- Lifetime aggregates (e.g., tickets per lifetime) that include post-t activity.
- Post-decision signals: cancellation-reason tickets, downgrade-driven billing changes, refunds, account-closure workflow fields.
- Latest-record values of
monthly_billing_amountinstead of as-of-t values. - Random row splits: the same customer leaks across snapshots. Use time-based splits (train before date D, test after), grouped by customer.
Censoring. In a classifier, a non-churned customer whose window ends before t+H has an unknown label; coding it 0 biases risk downward, especially for new users. Exclude them or adopt the hazard formulation. In survival, set duration = min(churn, censor) and δ only when churn observed. If observation starts after subscription (data begins mid-history), handle left truncation with entry times or you introduce immortal-time bias.
Cold start vs. tenured. New accounts have undefined or noisy login and ticket rates. Mitigate by including tenure explicitly, adding onboarding/activation features (setup completed, first-week logins, seats, plan, channel), and either segmenting models (tenure < 90 days vs. rest) or adding tenure-bucket interactions. Expect lower-confidence scores for new users and calibrate per segment.
3. Evaluation
Classifier at 2–5% prevalence. Accuracy is meaningless (predicting "no churn" scores 95–98%). Prioritize PR-AUC / average precision (baseline equals prevalence, so 0.25 at 3% is roughly 8× random), precision@k and recall@k where k = daily CS capacity (this is the business metric), and lift/capture in the top decile. ROC-AUC is fine for model comparison but optimistic under imbalance. F1 only after a threshold is fixed. Report Brier score and calibration curves, since probabilities feed expected-value math.
Survival. Harrell's C-index is the share of comparable pairs (shorter time is an event) where the higher-risk customer churns first — a global ranking measure across all horizons, not accuracy at 30 days; it can be inflated by easy long pairs and biased under heavy censoring. Complement with Uno's C (IPCW-weighted), time-dependent AUC at 30/60/90 days, integrated Brier score with IPCW, and calibration at the horizon against Kaplan–Meier observed rates by risk decile. To compare fairly, convert Cox to P(churn ≤ 30 days) and score both models with precision@k on the same time-split test set.
4. Operationalization
- Daily batch scoring of active customers with as-of-today features.
- Normalize to one quantity: 30-day churn probability. For Cox, conditional on current tenure τ: p = 1 − [S₀(τ+30)/S₀(τ)]^{exp(xᵀβ)}; for the classifier, use the calibrated probability.
- Rank by expected value at risk, p × MRR (or contract value), not raw probability — a 15% risk on a $5k/month account beats 40% on a $20 account.
- Cut at capacity (e.g., top 50/day), suppress accounts contacted in the last N days, route enterprise accounts to CSMs and the long tail to automated email.
- Attach reason codes from top SHAP values or Cox terms ("logins down 70%, 3 tickets this week") so the CSM knows the talking point.
- Hold out a random control group to measure incremental retention from outreach, not just correlation between contact and retention.
Common mistakes: using accuracy or uncalibrated scores; leaking post-cancellation signals into days_since_last_login; dropping censored users in a way that biases toward old cohorts; and optimizing ranking without regard to team capacity or account value. Common follow-ups include "how would you detect that churn drivers shifted?" (monitor PR-AUC and calibration by cohort, retrain on a schedule), "what about survival curves for brand-new users?" (weakly identified — shrink to plan-level baseline or rely on activation features), and "how do you set the 30-day window?" (align with the retention campaign's lead time and the CS team's response cadence).