# Data Leakage

> When the answers sneak into training. Test scores look great and real use fails.

**Field:** Artificial Intelligence  
**Category:** Machine Learning  
**Also known as:** Leakage, Target Leakage, Test Leakage

## Think of it like

Think of it like seeing the answers before a test. Your score is high, but you learned nothing.

## Definition

Data leakage is when facts the model should not have slip into its training. It might be test examples hiding in the training set. It might be a feature that gives away the answer. The model then scores very well in testing. Later, with real data, it does much worse.

## Example

Jack's model predicts which patients will get sick. One feature is the date the patient got medicine. That date gives the answer away, so the model looks perfect and fails in real use.

## Why it matters

It is one of the most common reasons a model that looked great fails after launch. Nothing warns you, because the scores look fine.

## Common mistake

Splitting the data after cleaning it all together. Steps like filling gaps should learn from the training set only.

## Three principles

- **Answers sneak in.** Facts the model should not have.
- **Scores too good.** Testing looks better than reality.
- **Fails for real.** New data shows the truth.

## Related terms

- [Test Set](https://learn.benibix.com/term/ai/test-set)
- [Training Set](https://learn.benibix.com/term/ai/training-set)
- [Feature (Machine Learning)](https://learn.benibix.com/term/ai/feature)
- [Validation Set](https://learn.benibix.com/term/ai/validation-set)
- [Benchmark Contamination](https://learn.benibix.com/term/ai/benchmark-contamination)

## Told apart from

- [Overfitting vs Data Leakage](https://learn.benibix.com/compare/overfitting-vs-data-leakage): People think a leak and overfitting are the same problem, since both make a model look better than it is. Overfitting is a model learning its training data too closely. It shows as a gap between the training score and the held-back score. A data leak is when facts from the test slip into training. It hides the gap, because the held-back score is high too. More data or a simpler model fixes overfitting. Only a cleaner split fixes a leak.

## Taught in

- [Training and Test Sets](https://learn.benibix.com/learn/ai-machine-learning/training-and-test-sets): Machine Learning, 2/18

![One long bar of data cut into three parts: a big training set, a smaller validation set and a smaller test set. A dashed arrow from the test set back into the training set is marked data leakage.](https://learn.benibix.com/diagrams/ml-data-splits.svg)

---

Source: https://learn.benibix.com/term/ai/data-leakage
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
