# Training and Test Sets

> Why data is cut into a training set, a validation set and a test set. How leaked answers make a model look better than it is.

**Course:** [Machine Learning](https://learn.benibix.com/learn/ai-machine-learning)  
**Time:** 11 min

**After this lesson you can:**

- Split data into three sets
- Say what each set is used for
- Spot data leakage before it fools you

## Why the data is split before training

Before a model learns, its data is cut into parts that never mix. A common split is about 70% for training, 15% for validation and 15% for testing. The model learns only from the training set. The other two are kept out, so they can show how it does on rows it has never seen.

The reason is simple. A model scored on the rows it learned from can just remember them. A pupil who has seen the exam answers scores 100% and may know nothing. Only fresh rows show whether the model found the real pattern.

The validation set is for the choices you make while you build. You train a few versions with different settings. You check each one on it and keep the best. Since you look at it again and again, its score slowly gets a bit too hopeful.

The test set is kept locked away until the very end. You use it once, for the final score, after every choice is made. If you peek and then change the model, it is no longer a fair test. Some teams hide it even from the people who train the model.

Data leakage is when facts the model should not have slip into training. Test rows may hide in the training set as copies. Or a feature may give the answer away, like a column filled in only after the event you want to predict. Leakage makes test scores look great and real use fail.

Time is a common trap. To predict next month's sales, train on the past and test on the latest months. A random split lets the model peek at the future, so it scores far better in testing than it ever will for real.

People often treat a high test score as proof. First ask how the rows were split, and whether any answer could have leaked in. How to score a model in depth, with more than one number, is a subject of its own. This lesson is about keeping that score honest.

![One bar of data cut into three parts: a training set of about 70% that the model learns from, a validation set of about 15% that is checked often, and a test set of about 15% that is used once. A warning below marks data leakage, when test rows slip into training.](https://learn.benibix.com/diagrams/ml-data-splits.svg)

### Example: Jack finds copied rows

Jack has 10,000 customer records and splits them 7,000, 1,500 and 1,500. His model scores 98% on the test set.

Then he finds 600 customers listed twice, once in training and once in testing. With the copies removed, the score drops to 85%, which is the real one.

**Words in this lesson:** [Training Set](https://learn.benibix.com/term/ai/training-set), [Validation Set](https://learn.benibix.com/term/ai/validation-set), [Test Set](https://learn.benibix.com/term/ai/test-set), [Data Leakage](https://learn.benibix.com/term/ai/data-leakage)

**Question:** Why keep a test set the model never sees?

**Answer:** To get a fair score on rows it has not seen. A model can remember the rows it learned from. Only rows it never saw show whether it found the real pattern.

---

Source: https://learn.benibix.com/learn/ai-machine-learning/training-and-test-sets
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-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
