
Spot Data Leakage with a Prediction-Time ChecklistData Science · INSIGHTData leakage happens when a model benefits from information that would not be legitimately available when making a prediction. A strong score can therefore conceal an unusable workflow. Review the timing of information before celebrating performance.
Define the prediction moment
Consider a fictional project predicting whether a support ticket will require escalation. Is the prediction made at submission, after initial triage, or after the first response? Write the moment precisely. A field can be valid at one moment and unavailable at another.
Inspect suspiciously helpful columns
A final escalation code obviously reveals the outcome. Less obvious examples include a resolution note written days later or a category manually changed after escalation. For each input, ask who creates it, when it is updated, and whether its historical value is retained.
Remove unavailable fields and document the reason. Do not merely rename them or assume that a numeric encoding makes them legitimate.
Separate learning from evaluation
Keep evaluation data outside fitting steps. Learned preprocessing, such as an imputation value or a scaling parameter, should come from the training portion. A pipeline can help organise the steps, but you still need to understand what information each step uses.
Challenge an unusually good result
Try a deliberately simple baseline and compare it with your model. Inspect examples with confident predictions. If near-perfect results disappear when a suspicious field is removed, investigate the data history rather than dismissing the lower score.
For practice, prepare a feature audit containing prediction time, field availability, and exclusion reasons. Include both the original flawed experiment and the corrected workflow, clearly labelled.
Technical reference: scikit-learn’s guidance on common pitfalls.
Created with AI assistance for JobJet. Illustrative exercises use fictional data; no employer outcomes are promised.