Spot and Fix Feature Leakage in a Churn Model
Machine LearningModel answerLast updated
Identify subtle data leakage in a customer churn prediction pipeline and explain how to fix it without sacrificing model utility.
Scenario
You are a junior ML engineer joining a team that built a binary classification model to predict whether a subscription customer will churn within the next 30 days. The model was trained on 12 months of historical data and achieved 94% AUC on a held-out test set — an unusually strong result.
During a code review, a senior engineer flags the feature list and raises concerns. The features used are:
| Feature | Description |
|---|---|
days_since_signup | Days between signup date and prediction date |
avg_session_duration_30d | Average session length over the past 30 days |
num_support_tickets_30d | Number of support tickets opened in the past 30 days |
cancellation_page_visits_30d | Number of visits to the cancellation page in the past 30 days |
plan_downgrade_flag | 1 if the customer downgraded their plan in the past 30 days |
num_logins_30d | Number of logins in the past 30 days |
final_nps_score | NPS survey score collected at the moment the customer churned or at month-end for active users |
The label is churned_in_next_30d (1 = churned, 0 = did not churn).
What is expected
- Identify which feature(s) contain leakage and explain precisely why.
- Describe the real-world failure mode: what happens when this model is deployed?
- Explain how to fix each leaky feature — either by removing it, transforming it, or replacing it with a leak-free alternative.
- Briefly describe how you would catch this kind of leakage earlier in the ML development process.
Hints
Hint 1
Think carefully about the timestamp at which each feature value would actually be known in production at prediction time — before the 30-day window begins.
Hint 2
The NPS score description contains a subtle timing issue. Ask yourself: when is that score collected for customers who churn?
Hint 3
High AUC alone is not evidence of a good model. What other signals — besides raw metric scores — should make you suspicious of a new model?
Model answer
Easy Try it yourself first — then compare your approach, complexity and edge cases.
1. Identifying the Leaky Features
Primary leakage: final_nps_score
This is the clearest and most damaging case of leakage. The feature description says the NPS score is collected at the moment the customer churned for users who did churn. That means, for every positive label (churned = 1), the NPS score reflects information that only became available after the churn event — i.e., after the label was determined.
At prediction time (today, before the 30-day window), you do not yet know whether the customer will churn, let alone have their post-churn NPS survey response. The model has essentially been handed the answer sheet.
Secondary / softer leakage: cancellation_page_visits_30d and plan_downgrade_flag
These features are not leaky in the strict temporal sense — both are observable before the label is determined — but they deserve scrutiny:
cancellation_page_visits_30d: Visiting the cancellation page strongly precedes and predicts churn, but it is a legitimate leading indicator as long as it is computed from the 30 days before the prediction date, not overlapping with the label window. You need to verify the time-window boundaries carefully. If the label window and the feature window overlap even partially, you have leakage.plan_downgrade_flag: Same reasoning. A downgrade in the past 30 days is legitimate. If any downgrade events from the future label window leaked in due to an off-by-one in date filtering, that is leakage.
These two features are worth auditing but are not definitively leaky from the description alone. final_nps_score is the main culprit explaining the 94% AUC.
2. Real-World Failure Mode
When this model is deployed in production:
- At prediction time,
final_nps_scorefor a current (not-yet-churned) customer is unavailable or reflects a stale, pre-churn survey — completely different from what the model trained on. - The model will receive a garbage value (missing, or an old score) and perform dramatically worse than the 94% AUC suggested.
- The team ships a "high-confidence" model, invests in retention campaigns, and then discovers the model barely beats a random baseline — costing time, money, and trust.
This pattern — suspiciously high offline metrics followed by production collapse — is one of the most common signs of leakage.
3. How to Fix Each Leaky Feature
final_nps_score — Remove or replace
- Remove it entirely. It cannot be used in any form because it is causally downstream of the label for churned users.
- Replace it with a leak-free alternative: the most recent NPS score collected before the prediction date (e.g.,
last_nps_score_before_cutoff). This is a genuinely available signal and a reasonable proxy for satisfaction.
cancellation_page_visits_30d and plan_downgrade_flag — Audit the time windows
- Confirm that the feature computation window ends strictly before the label window begins. For example, if the prediction date is day 0 and the label covers days 1–30, the features should use days −30 to 0 (or −29 to 0).
- Add a documented, tested
feature_cutoff_dateparameter to your pipeline that is enforced consistently.
4. How to Catch This Earlier
a) Temporal pipeline discipline
Define a strict cutoff_date for every training row. All features must be computable using only data with timestamp ≤ cutoff_date. Enforce this with automated checks or a feature store that timestamps each feature.
b) Sanity-check feature importances After training, always inspect the top features. If an unfamiliar or suspiciously direct feature (like an NPS score collected at churn) ranks at the top, treat that as a red flag until you can explain why it is available before the label.
c) Be skeptical of very high AUC on a hard problem A 94% AUC on churn — a notoriously noisy signal — should prompt immediate scrutiny, not celebration. Set internal team norms: any model that vastly exceeds baselines or prior art requires a leakage audit before merging.
d) Simulate production conditions in evaluation Run an offline simulation where features are fetched exactly as they would be in production (no post-label data). Alternatively, backtest on a recent time slice using only data that would have been available at that historical prediction date.
Common Mistakes Candidates Make
- Flagging only
final_nps_scorewithout explaining why it is leaky (the causal timing). - Claiming
cancellation_page_visits_30dis definitely leaky without checking the window definition — this shows imprecision. - Proposing to "just drop the NPS column" without suggesting what to replace it with, which leaves value on the table.
- Confusing train-test leakage (e.g., fitting a scaler on the full dataset) with label leakage (using future information in features) — these are related but distinct problems.