Data Leakage · Model Evaluation
LEAK = test set information contaminating training — model looks great until it hits the real world
Always split FIRST then transform — never fit transformers on the full dataset
L
Leakage source 1 — fitting transformers before splitting
Fitting a scaler, encoder, or PCA transformer on the entire dataset before splitting into train/test leaks test-set statistical information into what should be an untouched, unseen test set.
Example: computing a standardization scaler's mean and standard deviation using the full dataset, including test examples, before splitting off the test set.
E
Leakage source 2 — features unavailable at inference time
Including a feature in training that wouldn't actually be available at the moment the model needs to make a real-world prediction causes the model to rely on information it will never actually have access to in production.
Example: a hospital readmission model accidentally trained using a "discharge summary" field that's only written AFTER the outcome being predicted is already known.
A
Leakage source 3 — using future information for historical prediction
Accidentally including information from the future relative to the point in time a prediction is meant to be made, which the model would never actually have access to when making real predictions.
Example: predicting a customer's churn risk using a feature that reflects their account status one month AFTER the prediction point in question.
K
Detecting leakage — the telltale signs
Unrealistically high performance, feature importances that don't make logical or causal sense, and a dramatic performance drop once the model is deployed in production are all classic warning signs of data leakage.
Example: a model reporting 99.8% accuracy in testing, but performing dramatically worse once deployed to real, live data — a strong signal that leakage inflated the test results.
1
A model reports an unusually high 99.5% accuracy during testing, far exceeding what similar published models typically achieve on comparable tasks.
2
Ask: what should this unusually high performance immediately raise as a concern? Potential data leakage — the test performance may be artificially inflated rather than genuinely excellent.
3
Investigating further, the team discovers a feature was accidentally included that wouldn't actually be available at the real-world moment of prediction.
4
Removing that leaked feature and retraining produces a much more modest (but far more trustworthy and realistic) accuracy figure — one that will actually hold up once the model is deployed in production.

Exams test whether you can identify the three main sources of data leakage (fitting transformers before splitting, using inference-unavailable features, using future information) and whether you know the telltale warning signs (suspiciously high performance, illogical feature importances, production performance collapse).

The most common trap is assuming excellent test performance is always good news. Unrealistically high performance is often itself the first warning sign of data leakage, not confirmation the model is genuinely excellent — always investigate suspiciously strong results rather than simply celebrating them.

1. What is data leakage?
Information from outside the training set (test data, future information, or inference-unavailable features) contaminating the model, artificially inflating its apparent performance.
Tap to reveal / hide
2. Why does fitting transformers on the full dataset before splitting cause leakage?
Because it lets test-set statistical information influence the transformer, which is then applied to both training and test data.
Tap to reveal / hide
3. What kind of feature causes leakage related to inference-time availability?
A feature that wouldn't actually be available at the real-world moment the model needs to make its prediction.
Tap to reveal / hide
4. Name one telltale sign that a model may be suffering from data leakage.
Unrealistically high performance, feature importances that don't make causal sense, or a dramatic performance drop in production.
Tap to reveal / hide
5. Should unusually high test performance be treated as automatically good news?
No — it should be investigated as a potential warning sign of data leakage rather than assumed to reflect genuine model quality.
Tap to reveal / hide