KatInterview

Building a Production-Ready Churn Prediction System

Machine LearningModel answer
HardModel answerMachine Learningsupervised-learningdata-leakagemodel-evaluation

Last updated

Design and debug a user retention model: fix temporal leakage, implement proper validation, calibrate for business decisions, and establish monitoring.

You're working on a user retention model that predicts whether a customer will make a purchase within the next 28 days. Features are computed weekly from event logs. The existing model has problems with temporal data leakage and needs proper evaluation and productionization.

Address these aspects:

(a) Temporal leakage identification and repair

List at least five concrete examples of features that violate temporal constraints in event-based data (features that incorporate information from the prediction window itself). For each problematic feature, explain why it's invalid and provide a corrected version that respects the prediction-time cutoff.

(b) Validation strategy

Design a cross-validation approach appropriate for time-series data. Specify how you would partition training, validation, and holdout sets to prevent future information leakage. Address how to handle users who join or leave the platform and users with limited history.

(c) Decision-making with business constraints

The model achieves AUC 0.79 and precision-recall AUC 0.23 offline. An experiment targeting high-risk users shows 1.5% higher conversion but 0.3 percentage points more cancellations. Define relevant business metrics and describe how to set an operating threshold that accounts for costs and benefits. Explain how to ensure predicted probabilities are well-calibrated and how to detect calibration degradation over time.

(d) Coefficient analysis

A logistic regression coefficient for recent_orders_7d (standardized) is +0.40. The baseline log-odds is −1.50. Calculate the multiplicative change in odds for a one-standard-deviation increase and the resulting change in predicted probability. Discuss when coefficient-based interpretations can be misleading.

(e) Operational monitoring and maintenance

Outline what you would monitor once the model is deployed and define triggers for retraining. Include both data quality checks and performance metrics.

Hints

Hint 1

For temporal correctness, every feature must be computable using only events that occurred strictly before the prediction moment

Hint 2

Time-based splits need a gap between training and validation equal to the label window to avoid label overlap

Hint 3

Calibration maps scores to true probabilities; test it by bucketing predictions and comparing to observed rates

Hint 4

A positive coefficient on purchase history predicting churn is suspicious—check label encoding and feature correlation