What leakage is
Target leakage is when the feature set contains information that would not exist when the prediction is made. It is the single most common reason ML models look great in the notebook and disappoint in production. Leakage produces beautiful validation numbers and a model that cannot be deployed.
Three flavors
- Time leakage — using future aggregates (last-30-days revenue computed across the entire dataset).
- Post-event leakage — keeping columns that only exist after the outcome (cancel reason, refund amount, support call about the very issue).
- Preprocessing leakage — fitting a scaler, imputer, or encoder on the full dataset before splitting. Train statistics now know the test set.
Defense
Build features inside the pipeline, not before it. Split first, fit transformers on training only, and audit any column whose absence drops validation score by an unrealistic amount. If a single feature carries the model, it is leakage until proven otherwise.