Why Data Leakage Breaks AI Evaluations

Photo: Google DeepMind / Pexels
Data leakage happens when information that would never be available at real-world prediction time sneaks into a model's training or evaluation process, inflating its measured accuracy without improving its actual ability to generalize. A 2021 review in Nature Machine Intelligence, led by Michael Roberts and colleagues, examined 62 machine learning models built to detect COVID-19 from chest X-rays and CT scans and concluded that none were fit for clinical deployment, largely because of methodological flaws including leakage between training and test data (Roberts et al., 2021). Models that scored near-perfectly in testing had, in many cases, learned to exploit signals a real hospital would never hand them.
What leakage actually means, precisely
Data leakage occurs when information from outside the legitimate training dataset, information that would not exist in a genuine real-world prediction scenario, inadvertently influences a model during training or evaluation. The result is a performance number that looks earned but is not. The model has not cheated in any deliberate sense. It is doing exactly what it was built to do: finding patterns and exploiting them as efficiently as possible.
The trouble is that some of those patterns are artifacts of how the dataset was assembled rather than reflections of the underlying phenomenon the model is supposed to learn. A cancer-detection model that discovers a ruler in the corner of every malignant-tumor photo (because clinicians photographed larger, confirmed tumors next to a ruler for scale, and smaller benign ones without one) has learned "rulers predict cancer," not "this tissue pattern predicts cancer." That kind of finding is a well-documented category of failure in applied computer vision research, where spurious correlations between incidental image elements and diagnostic labels get picked up before anyone notices (Ribeiro, Singh, and Guestrin, 2016).
It helps to separate leakage conceptually from the two failure modes people usually blame instead: random noise and simple bad luck. Leakage is systematic. It is not that the model got unlucky on a handful of edge cases, it is that an entire signal running through the dataset is fake, and every score computed against that dataset inherits the fakery. That is what makes it so dangerous: it does not show up as instability or inconsistency. It shows up as a suspiciously clean, suspiciously stable, wrong number.
How leakage differs from ordinary overfitting
Overfitting means a model has memorized noise specific to its own training set, quirks that will not recur in new data, so its performance on a genuinely held-out test set exposes the gap. Leakage is a different failure entirely: the evaluation itself is contaminated, so even the held-out test score no longer means what everyone assumes it means. A guide to why training and test data must be separated covers the baseline discipline that leakage subverts, and the companion piece on why overfitting hurts machine learning explains the more familiar cousin of this problem. The two failures can and often do coexist in the same broken pipeline, but fixing one does not fix the other.
The classic case: leaking the answer through metadata
In the COVID-19 imaging studies Roberts and colleagues reviewed, several models achieved artificially high accuracy partly because scans from COVID-positive patients tended to come from different hospitals, or different scanner models, than scans from healthy controls. A model trained on that data could learn to recognize a hospital's or scanner's visual signature, things like a particular contrast profile, an imaging artifact, or a corner watermark, rather than the actual disease pattern in the lung tissue. On its own test set, drawn from the same lopsided hospital mix, the model looked outstanding. Deployed at a new hospital with a different scanner, none of that learned shortcut would transfer.
Think of it like a student who aces a practice exam not because they understand the material, but because the practice questions happened to be printed on a particular colored paper that, purely by coincidence, correlated with the correct answer letter in an old answer key the student half-remembered. The practice score looks excellent. It says nothing real about the student's actual command of the subject the moment the real exam uses ordinary white paper.
A closely related and extensively documented case is the "wolf versus husky" image classifier built by Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin for their 2016 paper introducing LIME (Local Interpretable Model-agnostic Explanations). The researchers deliberately trained a classifier on a dataset where nearly every wolf photo included snow in the background and nearly every husky photo did not. The resulting model achieved strong accuracy on its own held-out test images, images drawn from the same snow-correlated pool, but when the researchers used LIME to visualize which pixels actually drove each prediction, the model was overwhelmingly attending to the snowy background, not the animal (Ribeiro, Singh, and Guestrin, 2016). It had learned "snow predicts wolf," a rule that happens to work on a snow-correlated dataset and fails the instant a husky is photographed in snow or a wolf is photographed without it.
That example is usually taught as a lesson about interpretability, and it is one. But it is also a leakage story in miniature: the background feature is not literally future information or a target-derived proxy, yet it plays the same structural role as leakage in every other case in this article. It is a non-causal shortcut baked into how the dataset happened to be collected, and a plain accuracy score on a same-distribution test set cannot distinguish a model that learned the shortcut from a model that learned the real thing.
Temporal leakage: when the future contaminates the past
Temporal leakage occurs when a model is inadvertently given access to information from after the point in time it is meant to be predicting, a common and subtle failure in financial and operational forecasting. A stock-movement model that uses a company's quarterly earnings figure to predict same-day price movement, without accounting for the fact that earnings are released before markets react to them, can appear to "predict" the outcome accurately simply because its input already encodes information from the same moment as, or later than, the event it claims to forecast.
The same failure shows up constantly outside finance. A hospital readmission model that includes a feature for "total number of follow-up appointments scheduled after discharge" is quietly leaking the future into a prediction that is supposed to happen at the moment of discharge, before any of those appointments exist. A churn-prediction model trained on customer support logs that includes a feature like "opened a cancellation ticket" is predicting churn using a variable that is, for practical purposes, a confession of churn already in progress rather than a genuine early warning signal.
| Leakage type | What leaks | Real-world example | Why it inflates accuracy |
|---|---|---|---|
| Metadata leakage | Non-causal correlated signals (scanner, hospital, background) | Hospital/scanner identity correlating with COVID diagnosis (Roberts et al., 2021) | Model learns the incidental signature instead of the target pattern |
| Temporal leakage | Future information appearing before the point of prediction | Using post-earnings market data to "predict" same-day stock moves | Input already encodes the outcome or something downstream of it |
| Target leakage | A feature derived from, or a proxy for, the label itself | Using "sent to collections" to predict "will this loan default" | The feature is functionally a restatement of the answer |
| Train-test contamination | Overlapping or near-duplicate records across splits | Duplicate or near-duplicate patient scans split across train and test | The model partially memorizes records it will later be "tested" on |
| Group leakage | Related records from the same entity spread across splits | Multiple scans from one patient landing in both training and test sets | Model learns entity-specific quirks, not generalizable patterns |
Five leakage categories that share one underlying mechanism: the evaluation set contains information it should never have had access to.
Target leakage: when a feature secretly contains the answer
Target leakage happens when one of the input features used to train a model is itself derived from, or a close proxy for, the very outcome being predicted. A model built to predict whether a loan will default that includes a feature recording whether the loan was ever referred to a collections agency has effectively been handed the answer through a side door, since collections referral is a downstream consequence of default, not an independent signal available at the moment a real lending decision has to be made.
Target leakage is often harder to catch than metadata or temporal leakage because it can hide inside seemingly reasonable engineering choices. A feature named "average_claim_processing_days" in an insurance fraud model sounds like ordinary operational data. If claims flagged as fraudulent take systematically longer to process, precisely because investigators spend more time scrutinizing them, that processing-time feature becomes a near-direct proxy for the fraud label itself. The fix is not to distrust every feature reflexively, it is to ask, for each one, whether it would exist and hold that same value at the actual moment a real prediction has to be made, before the outcome is known.
Feature engineering choices are exactly where this kind of contamination gets introduced or avoided, which is why the practical guide on what feature engineering means is worth pairing with this one: every new derived feature is a fresh opportunity for target leakage to sneak back in.
Why cross-validation setups can silently leak too
Even a carefully executed train-test split can leak information if related records end up split across both sets, a failure mode generally called group leakage. A medical imaging dataset containing multiple scans from the same patient leaks information the moment some of that patient's scans land in the training set and others land in the test set. The model can then learn patient-specific anatomical quirks, the exact shape of a rib cage, a particular positioning habit from that patient's imaging sessions, rather than genuinely generalizable diagnostic patterns. Its accuracy on that patient's held-out scan is inflated by prior exposure to that same patient's tissue, not by real diagnostic skill.
Cross-validation, the standard technique of rotating which slice of data is used for testing across several rounds, does not automatically fix this. A naive k-fold split applied to patient records without first grouping by patient ID will happily scatter one patient's ten scans across five different folds, contaminating every single fold in exactly the way a single train-test split would. The fix, group-aware cross-validation, ensures that the unit of splitting is the patient (or customer, sensor, or whatever entity generates the correlated records), not the individual row. Every one of that patient's records stays entirely on one side of the split, always.
Duplicate and near-duplicate records: a quieter version of the same problem
A closely related and well-documented issue is train-test contamination through duplicate or near-duplicate records, a problem that surfaces even without any grouping structure at all. Large image and text datasets scraped or aggregated from multiple sources frequently contain exact duplicates or near-duplicates, the same photo saved at two resolutions, the same product review copy-pasted across two listings, the same news article syndicated to three outlets and captured twice during data collection. If a naive random split places one copy in training and its near-identical twin in testing, the model does not need to generalize at all to score well on that test example. It only needs to recall something close to what it already memorized. This is a recognized risk in large-scale benchmark construction generally, and it is one reason serious dataset-curation pipelines run explicit deduplication passes, often using near-duplicate detection methods like perceptual hashing for images or n-gram overlap checks for text, before any split is drawn.
How rigorous teams actually prevent leakage
Preventing leakage starts with establishing a strict, explicit boundary: what information would genuinely be available at the exact moment a real-world prediction gets made, no earlier and no later, and auditing every single feature against that boundary before training begins. This is a discipline, not a one-time checklist item. Feature stores, engineering pipelines, and dataset updates all create fresh opportunities for the boundary to get silently crossed months after the original model was validated cleanly.
A few concrete practices recur across teams that manage to avoid these failures consistently.
- Group-aware splitting. Every record belonging to the same underlying entity, patient, customer, device, household, stays entirely within one split, training or test, never both.
- Temporal ordering. For any forecasting or time-sensitive task, the test set is drawn from time periods strictly after the training set, and features are computed using only information that would have existed at prediction time.
- Feature provenance audits. Every feature gets traced back to its source and timestamp so a reviewer can answer, in one sentence, "would this value have existed before the outcome I'm predicting."
- Deduplication before splitting. Near-duplicate detection runs on the full dataset before any train-test division, not after.
- Held-out final test sets. A slice of data is set aside and touched exactly once, at the very end, specifically because repeated peeking at a "held-out" set during model development is itself a mild form of leakage through the researcher's own decision-making.
- Suspicion of unusually high scores. A result that looks too good relative to the genuine difficulty of the task is treated as a signal to investigate the pipeline, not a reason to celebrate.
None of these practices is exotic or expensive to implement. What they require is discipline applied consistently across every dataset refresh and every new feature, which is precisely where teams under deadline pressure tend to cut corners.
Common misconceptions
A common misunderstanding is that data leakage is primarily a mistake made by inexperienced practitioners, something a senior team would obviously catch. The Nature Machine Intelligence review of COVID-19 imaging models found leakage-related methodological flaws across a wide range of published, peer-reviewed research from institutions with substantial machine learning expertise, indicating that leakage is a subtle trap that survives review by experienced researchers working under ordinary publication and time pressure (Roberts et al., 2021).
Another misconception is that a model performing exceptionally well during evaluation is inherently strong evidence of a good model. In practice, the opposite instinct is often more useful: accuracy that seems too good relative to how genuinely difficult the underlying task is should prompt scrutiny for possible leakage before it prompts a celebration. The LIME wolf-versus-husky classifier looked like a competent animal classifier right up until someone actually inspected what pixels it was using (Ribeiro, Singh, and Guestrin, 2016).
A third misconception is that leakage is only a risk in small or amateur datasets. Large, well-funded, professionally curated datasets are not immune. Scale does not fix a structural flaw in how a dataset was assembled or split, it can even make the flaw harder to spot, because there is more data to review and more distance between the people building the pipeline and the people who understand the original data-collection process closely enough to notice something is off.
A fourth misconception worth naming directly is that leakage is purely a technical bug with a technical fix, something a better cross-validation library solves on its own. Off-the-shelf cross-validation tools happily perform naive random splits by default unless a practitioner explicitly configures grouping or temporal ordering. The tool is not wrong, it is doing exactly what a generic k-fold splitter is supposed to do. The responsibility for recognizing that a particular dataset has grouping or temporal structure that a generic splitter will violate sits with the person designing the evaluation, not with the library.
What this means for anyone reading an AI performance claim
For anyone outside the modeling team, a headline accuracy number is close to meaningless without knowing how the evaluation was constructed. A useful habit is to ask three questions whenever a striking machine learning result gets published or announced: was the test set drawn from a genuinely different time period or population than the training set, were related records (same patient, same customer, same device) kept entirely on one side of the split, and does any input feature encode information that would not have existed at the actual moment of prediction. A paper, product page, or press release that cannot answer those three questions clearly is not necessarily wrong, but it has not yet earned the accuracy number it is reporting.
This scrutiny matters more, not less, as machine learning gets deployed into higher-stakes domains. A leaked evaluation in an academic benchmark wastes research time. A leaked evaluation behind a clinical diagnostic tool, a loan-approval system, or a fraud-detection pipeline can cause real harm once the gap between the reported number and reality surfaces in production, often after the system has already been making consequential decisions for months.
The takeaway
Data leakage breaks AI evaluations by contaminating the very measurement meant to reveal whether a model actually works, so the resulting accuracy score describes an artifact of how the data happened to be collected rather than the model's genuine ability to generalize to new, real-world cases. The COVID-19 imaging review and the LIME wolf-versus-husky classifier are two very different demonstrations of the same underlying lesson: leakage survives ordinary scrutiny, looks like success right up until deployment, and only becomes visible once someone deliberately checks what signal the model is actually using rather than trusting the number it produced.
Read next:
- Why training and test data must be separated
- Why overfitting hurts machine learning
- What feature engineering means
FAQ
Q: What is data leakage in machine learning?
Data leakage occurs when information that would not genuinely be available at real-world prediction time inadvertently influences a model during training or evaluation, causing measured accuracy to be artificially inflated compared to real-world performance.
Q: How is data leakage different from overfitting?
Overfitting means a model has memorized noise specific to its training data. Leakage means the evaluation process itself is contaminated, so even a model's held-out test score no longer honestly reflects real generalization performance.
Q: What did the 2021 review of COVID-19 imaging AI models find?
Michael Roberts and colleagues, publishing in Nature Machine Intelligence, reviewed 62 published models for COVID-19 diagnosis from chest imaging and found none suitable for actual clinical use, citing methodological flaws including data leakage between training and test data.
Q: What was the wolf-versus-husky classifier example, and what did it show?
Researchers Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin trained a classifier on images where wolves appeared mostly in snow and huskies did not, then used their LIME explainability method to reveal the model was predicting "wolf" based on snowy backgrounds rather than the animal itself, despite scoring well on same-distribution test data.
Q: What is group leakage, and why does it matter?
Group leakage occurs when related records, such as multiple scans from the same patient, are split across both the training and test sets, letting a model learn entity-specific patterns rather than genuinely generalizable ones, inflating apparent accuracy without reflecting real predictive skill.
Q: What is target leakage?
Target leakage happens when a model's input features include data derived from, or functioning as a proxy for, the outcome being predicted, such as using a loan's collections-referral status to predict whether that same loan defaulted.
Q: How can data leakage be prevented?
Preventing leakage requires auditing every feature against a strict boundary of what information would genuinely be available at real-world prediction time, using group-aware data splitting so related records stay entirely within one split, deduplicating datasets before splitting, and respecting temporal ordering in forecasting contexts.
Follow new articles
Add SciHub101 to your feed reader to see new science and technology stories.
About the Author
SciHub101 is an independent science and technology publication founded and edited by Buğra Sözeri, a software engineer and app developer based in Türkiye. AI tools assist with drafting and research. Source documentation in the existing archive is uneven, and articles are being reviewed and corrected. The Editorial Team byline identifies editorial responsibility; it does not certify specialist or independent human review. Where we compare products, anything built by our own team is labelled as such — see the editorial guidelines and About page for how corrections and disclosures work.
Related Articles




Overfitting & Underfitting — ML Bias-Variance Tradeoff
Overfitting and underfitting in ML explained simply: bias-variance tradeoff, how to detect, regularization, cross-validation, and practical fixes for both.
Why 99% Accuracy Can Be Useless: Precision and Recall
Why 99% accuracy can be useless: how the confusion matrix, precision, recall, F1, and PR curves behave on imbalanced data, with a fully worked example.
