MACHINE LEARNING • LESSON 4

Training vs Validation vs Test

Training, validation, and test data all come from the dataset, but each has a different job in the Machine Learning workflow.

THE CORE IDEA

Learn with training data, make development decisions with validation data, and perform the final evaluation with test data.

Keeping these roles separate helps us understand whether a model can generalize beyond the examples used during development.

01

The Three Datasets at a Glance

TRAINING DATA Learn

Used by the model to learn patterns from examples.

VALIDATION DATA Choose

Used during development to compare approaches and make decisions.

TEST DATA Evaluate

Used for the final evaluation of the selected model.

02

Think of Them as Three Different Jobs

1 Training

Teach the model using known examples.

2 Validation

Compare and improve the model during development.

3 Test

Measure the final model on held-out examples.

03

A Concrete Example

Suppose we have 10,000 labeled house records.

For learning purposes, imagine we split them like this:

8,000 Training
1,000 Validation
1,000 Test

The percentages shown here are only an example. Real projects may use different strategies depending on the dataset and problem.

04

Step 1: Training

The model first receives the training data.

TRAINING Features + Labels

The model learns relationships from the training examples.

For a house-price problem, the model might learn relationships involving size, bedrooms, location, age, and other available features.

05

Step 2: Validation

After training, we can evaluate the model on the validation data.

VALIDATION Compare and Improve

Use validation results to decide which model or approach should move forward.

We might discover that one model performs better than another on the validation examples.

06

Step 3: Final Test

Once we have finished making development decisions, we evaluate the selected model using the test data.

TEST Final Evaluation

Measure the final model on data kept separate from the development process.

07

What Happens If We Mix Them Up?

The roles are not interchangeable.

Mistake 1

Training on the test data makes the test result less meaningful.

Mistake 2

Repeatedly changing the model based on the test result turns the test set into part of development.

08

The Most Important Difference

TRAINING "Learn from this."
VALIDATION "Which approach is better?"
TEST "How good is the final model?"
09

A Student Analogy

Think about learning for an exam.

TRAINING Study Material

You learn concepts and practice problems.

VALIDATION Mock Exam

You check your weaknesses and adjust your preparation.

TEST Final Exam

You are evaluated on questions you did not use for preparation decisions.

10

What If We Only Have Training and Test Data?

You do not always need a separate validation set.

For simple projects, a training/test split can be perfectly reasonable.

Example

You might train a model on 80% of the data and reserve 20% for final evaluation.

The important principle is not blindly following a percentage. The important principle is keeping the final evaluation independent from model development.

11

The Complete Workflow

01 Collect Data

Gather examples relevant to the problem.

02 Split Data

Separate training, validation, and test data when appropriate.

03 Train

Learn patterns from training data.

04 Validate

Compare and improve the model.

05 Test

Perform the final evaluation.

12

Quick Comparison

Dataset Main Purpose Used During Training? Used for Final Evaluation?
Training Learn patterns Yes No
Validation Compare and improve No No
Test Final evaluation No Yes
KEY IDEA

Remember the Three Words

Training = Learn.
Validation = Choose.
Test = Evaluate.

QUICK CHECK

Which Dataset?

You have trained three different models and now want to decide which one should be used.

Which dataset should normally help you make that development decision?

Answer

Validation data.

After selecting the final approach, the test data should be used for the final evaluation.

NEXT TOPIC

A Simple Dataset Split

Now let's take a real dataset and walk through how the samples can be divided into training, validation, and test sets.