KatInterview

Predict customer spend with zero-inflated heavy-tailed regression

Machine LearningModel answer
HardModel answerMachine Learningregressionfeature-engineeringmodel-validation

Last updated

Build a complete pipeline to forecast 90-day customer value from marketing and behavioral data, addressing zero inflation, multicollinearity, and leakage.

You are tasked with building a regression system to forecast 90-day customer spending at the individual level. The target exhibits two challenging properties: many customers spend nothing (creating a spike at zero), and a small subset generates extremely high revenue (creating a long right tail).

Available input signals include:

  • Channel-specific marketing expenditure (search, social, display)
  • Behavioral metrics capturing recency, frequency, and monetary patterns
  • Device category and geographic location
  • Duration since account creation
  • Several hundred sparse campaign identifiers with high cardinality

Data complications you must address:

  • Marketing spend features are highly correlated with each other
  • Prediction uncertainty grows as predicted values increase
  • Feature-target relationships may be nonlinear
  • Data arrives with natural time ordering across multiple periods

Your task is to architect a complete modeling solution covering:

  1. Distribution and loss: Select and defend a loss function and distributional family appropriate for zero-inflated, heavy-tailed outcomes
  2. Feature transformations: Process continuous variables, encode high-cardinality categories without introducing leakage, and consolidate rare levels
  3. Penalty methods: Mitigate correlation through penalized estimation; derive the elastic net loss and explain when L1 versus L2 terms dominate
  4. Temporal validation: Construct a cross-validation framework that respects time dependencies and prevents future information from contaminating training
  5. Assumption checking: Identify and correct heteroskedasticity, nonlinearity, and outlier influence
  6. Prediction intervals: Generate well-calibrated uncertainty estimates and contrast different interval construction methods
  7. Model interpretation: Explain how you extract insight from linear model coefficients versus tree-based feature attributions
  8. Leakage mitigation: Enumerate the major sources of data leakage in this pipeline and describe prevention strategies
  9. Model comparison: Evaluate regularized linear models against gradient boosting across performance, interpretability, and stability dimensions

Hints

Hint 1

Distributions that accommodate exact zeros alongside continuous positive values are well-suited to revenue prediction

Hint 2

When encoding categories using target statistics, compute them out-of-sample within your training data to avoid overfitting

Hint 3

Temporal validation must account for the 90-day measurement window and block all future-dated information from training