Write down what the model knows when it predicts
Define a prediction moment and list the features the model can actually see then. Leakage occurs when training or evaluation uses information that would be unavailable in the real prediction workflow. It can make a model look excellent on a test set while hiding failures when the same features are missing later.
Example one. A feature created after the outcome
Suppose you predict whether a support ticket will be escalated using fields available at opening. The final escalation reason is a tempting feature but is only written after the event. Remove it from the feature list and check when other status fields populate. Keep the label separate from inputs.
Example two. The same source appears in both splits
If several images come from one event or customer, a random row split can put nearly identical items in training and testing. Group the examples by their common source before splitting. For a forecast, consider whether a chronological split better matches the way future data arrives.
Example three. Preprocessing learns from held-out data
If you fit a scaler or imputer on all rows before splitting, the model pipeline learns summary statistics from evaluation data. Fit preprocessing on the training portion and apply that fitted transformation to validation and test rows. In cross-validation, do this inside each fold through a pipeline.
Make a short leakage review part of evaluation
Record each feature’s source and earliest availability. Search for duplicate groups across splits and compare implausibly strong features with domain expectations. Re-run the evaluation after correcting the issue and report the revised metric. Keep any final test set outside the model selection loop.
Related guides
Further reading. Scikit-learn guidance on data leakage.
