Data Leakage

The deepest module. Target, temporal, entity, preprocessing, feature and evaluation leakage: every way information from the answer reaches the model, and why each makes offline metrics lie.

Data Leakage
▶ lab

Leakage is information from the answer reaching the model during training through a route that will not exist at prediction time. The offline metric improves; the product does not.

Q · Validation is excellent and production is mediocre, with no skew, no drift and no bug in the serving path. How does information from the label get into the features, and why does the evaluation not notice?
Target Leakage
▶ lab

A feature that is derived from, caused by, or written by the same process as the label. It looks like a column; it is the answer.

Q · A feature predicts the label almost perfectly on the training table. How do you tell whether you have found a strong signal or a copy of the answer?
Temporal Leakage
▶ lab

Information from after the prediction time reaches the features: a future timestamp, a window that crosses the snapshot, a random split of time-ordered data.

Q · The features are honest columns and none of them is the label. How can they still know the future, and why does a random split hide it?
Entity Leakage
▶ lab

The same user, patient or device appears on both sides of the split. The model memorises the entity, the evaluation rewards it, and production is full of strangers.

Q · Every feature is honest and every window is correct. Why does a random row split still overstate how the model will do on people it has never seen?
Preprocessing Leakage
▶ lab

A scaler, imputer, encoder or feature selector fitted on the full dataset before the split has seen the validation rows. The order of operations is the leak.

Q · No feature knows the future and no entity straddles the split. How can a normaliser leak, and why is the fix a matter of ordering rather than of columns?
Evaluation Leakage

The data is clean and the pipeline is ordered correctly. The leak is the engineer: tuning on the test set, peeking repeatedly, picking the best of many runs on one holdout.

Q · Every feature, split and preprocessing step is correct. How does the test number still become an overestimate, and why is the cause a process rather than a column?
The Leakage Audit

A checklist run on every feature before the offline number is believed: when is it computed, from what, is it available at prediction time, does it correlate suspiciously, is it near-perfect on a subgroup.

Q · The validation number is too good. What do you check, in what order, to find the leak before anyone commits to the number?