What is data leakage in machine learning?
Information unavailable at prediction time leaks into training, inflating test metrics artificially.
Data leakage (not to be confused with a data breach in the cybersecurity sense, a different meaning covered by data security) is the phenomenon where information unavailable at the real moment of prediction leaks into the data used to train or validate a model. The result is a model that looks excellent in development, with very high validation metrics, and collapses as soon as it reaches production, because there that "future" or forbidden information simply does not exist yet. It is one of the most common, and most insidious, causes of a machine learning project that seemed ready and was not: the problem does not show up in internal tests, because the test itself is contaminated by the same flaw, only downstream. That is also why data leakage should be kept distinct from reward hacking, which is about a model gaming the objective despite clean data: here it is the measurement itself that is distorted upstream.
See also: Model monitoringModel monitoring tracks the data, predictions, and outcomes of models in production to detect changes and decide when their performance calls for action.
The concrete forms
The most direct form is a variable that already contains the outcome, sometimes under an innocent name: a "case closed status" field that effectively encodes whether the customer purchased, used to predict that very purchase. Then there are transformations computed on the whole dataset before the train/test split: normalizing, imputing missing values or selecting features using test data too means the model indirectly "sees" information it should not have access to. On data with a temporal order, a random split instead of a chronological one lets the model learn from the future to predict the past, a frequent and nearly invisible mistake without explicit checks. There are also duplicates or near-duplicates between training and test (same customer, same transaction, nearly identical records ending up on both sides), and information coming from tables updated after the fact, where the value seen today is not the one that would have been available at prediction time.
A typical enterprise case
It is the most frequent explanation behind the classic "it worked great in testing, not in production". A default risk scoring model trained on a history where the "days of payment delay" field gets populated even for already closed cases shows near-perfect accuracy in validation, because that field is effectively a snapshot of the final outcome. In production, where the model must decide before that information exists, performance collapses. Anyone doing due diligence on a model vendor or an internal project should treat suspiciously high accuracy as a risk signal, not good news, until the temporal provenance of every feature has been verified.
The minimum checks to demand
Before trusting a result: verify that every feature was genuinely available at prediction time, with timestamps in hand; check that normalization, imputation and feature selection were computed only on the training set; use a temporal split, not a random one, on data with a chronological sequence; look for duplicates between training and test at the entity level, not just the row level; and finally test the model on a batch of truly new data, never seen in any phase, as a last check before release. Ongoing model monitoring in production still remains the final safety net, because even a careful review can let a subtle contamination through.
Related terms
- Model monitoringModel monitoring tracks the data, predictions, and outcomes of models in production to detect changes and decide when their performance calls for action.
- Evals (model evaluation)Evals are systematic assessments that measure an AI system against defined cases and criteria, helping teams compare versions and understand its risks.
- Data qualityHow fit your data is for its intended use: complete, correct, fresh and consistent across systems. Measured, not declared.
- Data debtData debt is the future work caused by neglected data, definitions, and dependencies, which make information more costly and risky for an organization to use.
- Reward hackingReward hacking occurs when an AI system exploits a reward or evaluation criterion to earn a high score without achieving the goal the criterion represents.