MACHINE LEARNING • LESSON 4

Training vs Validation vs Test

A machine learning dataset can be divided into three important parts: training data, validation data, and test data. Each part has a different job.

THE SIMPLEST WAY TO REMEMBER

Train → Decide → Test

Training data teaches the model. Validation data helps us make decisions while developing the model. Test data gives us the final evaluation after development is finished.

01

The Three Parts

Think of the dataset as one large collection of examples that we divide according to purpose.

01 • TRAINING Learn

The model learns patterns from these examples.

02 • VALIDATION Decide

We use these examples to compare choices and improve the model during development.

03 • TEST Evaluate

We use these examples for the final evaluation of the finished model.

02

Training Data — "Learn From This"

Training data is the data the model learns from.

The model studies these examples and learns relationships or patterns that can help it make predictions.

QUESTION What is the model doing?
ANSWER Learning patterns

For example, if we are predicting house prices, the training data may contain house size, number of bedrooms, location, and actual prices.

INPUT 2,000 sq ft
BEDROOMS 3
LOCATION City A
ACTUAL PRICE $400,000

By studying many such examples, the model learns useful relationships between the input information and the price.

03

Validation Data — "Help Me Decide"

Validation data is used while we are developing the model.

Suppose we have two possible models. We can use validation data to compare them and decide which one appears to perform better.

MODEL A Validation error: 30%
vs
MODEL B Validation error: 18%

Based on the validation result, we might choose Model B for further development.

So validation data answers a question like:

"Which choice should we use while building the model?"
04

Test Data — "How Good Is the Final Model?"

Test data is kept separate until the model development process is finished.

Once we have chosen the model and its important settings, we use the test data for the final evaluation.

MODEL IS FINISHED No more major decisions
TEST DATA Final performance check

Test data answers a different question:

"How well does the finished model perform on unseen data?"
05

One Simple Example

Imagine you are building a model that identifies whether an email is spam.

You have 10,000 labeled emails.

The three groups contain similar types of information, but their purpose is different.

06

The Exam Analogy

One of the easiest ways to remember the difference is to think about learning for an exam.

TRAINING Study

Learn the subject from lessons and practice material.

VALIDATION Practice exam

Check progress and decide what needs improvement.

TEST Final exam

Measure the final result using questions not used during preparation.

This analogy is not a perfect technical description, but it is a useful way to remember the purpose of each data split.

07

The Biggest Difference

The biggest difference is not the type of data. It is what we use the data for.

DATA PURPOSE
Training Teach the model
Validation Guide development and compare choices
Test Final evaluation
08

The Complete Picture

Now we can put everything together.

TRAINING DATA Learn Model learns patterns.
VALIDATION DATA Decide Compare, tune, and improve.
TEST DATA Evaluate Measure the finished model.
KEY IDEA

Train the Model. Use Validation to Develop It. Use Test Data to Judge the Final Model.

Training, validation, and test data are not three different types of machine learning. They are three different roles that portions of the dataset can play during the model-building process.

QUICK CHECK

Can You Identify Each One?

1. The model needs examples to learn patterns.

Training Data

2. You want to compare two models and decide which one to continue developing.

Validation Data

3. The model is finished and you want one final evaluation using data that was kept separate.

Test Data
NEXT TOPIC

A Simple Dataset Split

Now that we understand the three roles, we will see how a real dataset can be divided into training, validation, and test portions.