Skip to content

AI Glossary · Concepts

What is Data Leakage?

Data Leakage

Data leakage happens when a model is trained or evaluated using information it would not actually have at prediction time, such as test examples slipping into training or a feature that secretly encodes the answer. The result is scores that look far better than real-world performance.

Also known as: target leakage, label leakage, train-test contamination

· Chain of Thought

Model TrainingAI Evaluation & Reliability

  • 3 sources

A retailer builds a model to predict which orders will be returned. Accuracy in testing is spectacular. In production it is barely better than guessing. The cause: one input column was “refund processed,” which is only filled in after a return happens. The model learned to read the answer off that column. Google’s glossary gives a similar example of a “spoke to customer agent” flag that only gets set after a purchase.

Leaks come in a few common shapes. Target leakage is a feature that is a stand-in for the answer. Train-test contamination is the same or near-duplicate examples on both sides of the train/test split. Preprocessing leakage, highlighted by scikit-learn, comes from computing averages or feature scaling over the full dataset before splitting. Temporal leakage is training on data from after the moment you’re predicting, a constant risk in time-series forecasting.

This is not a beginner-only mistake. Kapoor and Narayanan found leakage errors in 329 published papers across 17 fields. Prevention is mostly discipline: split first, fit every preprocessing step on training data only, check that each feature would exist at prediction time, and treat a suspiciously good score as a bug until proven otherwise. In the LLM world the closest cousin is benchmark contamination, where test questions end up in pre-training data. The security sense of “data leak,” exposing private information, is a different problem; see token leakage for one example.

Sources