AI GLOSSARY · AI CONCEPTS

Data leakage (machine learning)

Markdown version

Definition

Data leakage in machine-learning evaluation occurs when information unavailable in the intended prediction setting influences model development or testing. It can make performance estimates misleading; it does not guarantee a particular score or failure on every new example.

Also called: train test leakage, leakage in machine learning, data leakage in ML.

In plain language

Imagine a student who sees the exam answers while studying, then sits the exam and scores well. The score is not a valid independent check of what they learned. Data leakage is the same mistake in machine learning: information from the test, or from the future, slips into the material a model learns from, so the test result may overstate generalization. It happens through small slips, such as scaling a whole dataset before splitting it, or including a column that is only filled in after the outcome is known. The main limitation is that leakage is hard to see from the score alone, because a reported score alone may not reveal contamination. The risk is a team shipping a model, or an evaluation of an AI feature, that may not have been as good as reported.

Technical definition

scikit-learn's documentation defines leakage as information that would not be available at prediction time being used when building the model, which gives overly optimistic performance estimates, for example from cross-validation. IBM names two types: target leakage, where the model uses data that will not exist at prediction time, and train-test contamination, where training and validation data are mixed, often through improper splitting or preprocessing. Typical mechanisms are fitting a scaler, imputer or feature selector on all rows before the split, and duplicate or grouped rows landing on both sides. A common remedy is to fit every preprocessing step inside a pipeline so it only sees the training fold.

Worked examples in this catalogue

Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.

  1. Skill by Skill Almanac · Illustrative, not executed

    split-leakage-check 53/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    It checks train, validation and test files for duplicates, shared groups, time and label leakage, and prints a JSON report.
    Why it exercises the concept
    These are the leakage routes the definition names: rows or groups on both sides of a split, future information, and label information. A flagged finding is the concept made visible in your own files.
  2. Skill by Skill Almanac · Illustrative, not executed

    llm-eval-test-sets 57/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    It builds and validates an eval dataset for an LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.
    Why it exercises the concept
    Leakage is not only a classic-model problem. If test items overlap with what a prompt, example set or fine-tune saw, the eval score is optimistic in the same way.
  3. Skill by Skill Almanac · Illustrative, not executed

    data-analysis-eda 56/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    It follows a fixed exploratory-analysis procedure with a CSV profiler, keeping findings descriptive, evidenced and caveated.
    Why it exercises the concept
    This is an adjacent case, not a leakage tool. Profiling a dataset before modelling is where a suspicious column, such as one filled in after the outcome, is often first noticed. The catalogue has no model-training skills.

How it shows up when you use agents

When a coding agent builds a model for you, it writes the whole workflow: load the data, clean it, split it, fit, score. An incorrect order of fitting, splitting and evaluation can introduce leakage. An agent that normalises the full dataset and then splits it, or splits rows at random when they are time-ordered, can report a strong score that real data will not match.

The same idea applies to LLM benchmark results and to your own evals. If test questions appeared in a prompt, a few-shot example or training data, the evaluation may no longer be an independent test of the intended capability.

What breaks when this is misunderstood: you trust a high number and ship. A safer habit is to ask the agent to show, in code, which rows each preprocessing step was fitted on, and to put those steps in a pipeline so they only see training data, which scikit-learn's documentation recommends. Check time-ordered data by splitting chronologically, as IBM advises. Then run skill-almanac/split-leakage-check on the split files. A related failure is overfitting, where fitting training-specific patterns harms generalization; leakage can hide it by making the test score look fine.

Worked example (illustrative)

Imagine selecting features using both training and test labels, then reporting performance on those same test rows. The test data has influenced model selection, so it is no longer an independent holdout. Refitting selection only on training folds addresses that route of contamination. It does not, by itself, rule out duplicates, temporal leakage or other evaluation flaws.

Common confusions

  • Data leakage versus a data breach. A breach is data reaching people who should not have it. Leakage in machine learning is information crossing from test or future data into model building. No one needs to steal anything.
  • Leakage versus overfitting. Overfitting is fitting training-specific patterns that do not generalize well. Leakage is a flaw in how the data was split or prepared. They can occur together, and leakage can make overfitting invisible.
  • Target leakage versus train-test contamination. IBM separates a feature that would not exist at prediction time from a split that mixes training and validation data.
  • Myth: a very high score proves the model is good. An unexpectedly high score is one reason to look for leakage.

Terms that mention Data leakage (machine learning)

5 terms mention this one

More in AI concepts

Next steps

  1. split-leakage-check A skill that exercises it.
  2. Machine learning (ML) Related term.
  3. Training data Related term.
  4. All glossary terms A to Z and by family.

Sources

Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-24. Wikipedia is never the only source.

Review record

Last verified

Drafted by Claude (original draft) and Codex (automated revisions); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-24. Last verified .

Change log (6)
  • : Independent automated factual/example review completed. Cached US query estimate aligned to receipt; no traffic promise. Final technical gate recorded separately; publication disabled.
  • : First version.
  • : Verifier pass: corrected claims against sources.
  • : Trust and evaluation scope corrections; independent exact-version review pending.
  • : Demand metadata uses a receipt-verified US ML-qualified definition query; independent content review remains pending.
  • : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.