MACHINE LEARNING • LESSON 3

Training a Model

Training is the stage where a machine learning model learns patterns from data. The model looks at examples, compares its predictions with the known answers, and adjusts itself so it can make better predictions.

THE CORE IDEA

Training means learning patterns from examples.

We give the model training data containing useful examples. The model studies those examples and learns a relationship between the input information and the expected output.

01

What Is a Model?

A model is the part of a machine learning system that learns patterns from data.

For example, suppose we want to predict house prices. We can give the model information about houses and their actual prices.

INPUT House size, bedrooms, location
MODEL Learns patterns
OUTPUT Predicted price

During training, the model learns how the input information is related to the output.

02

What Does Training Data Contain?

In supervised learning, training data contains examples where the correct answer is already known.

For example, a house-price dataset could look like this:

Size Bedrooms Actual Price
1,000 sq ft 2 $200,000
1,500 sq ft 3 $300,000
2,000 sq ft 4 $400,000

The model receives the house information and knows the actual price for each training example.

It uses these examples to learn the relationship between the inputs and the answers.

03

How Does the Model Learn?

The basic idea is simple.

The model makes a prediction, compares that prediction with the known answer, and adjusts itself when the prediction is not good enough.

1 Give Example

Provide the model with training data.

2 Make Prediction

The model produces an answer.

3 Compare

Compare the prediction with the actual answer.

4 Adjust

The model changes its learned parameters to improve.

This process happens across many training examples.

04

A Simple Example

Imagine we give the model information about a house:

HOUSE 1,500 sq ft

3 bedrooms

MODEL PREDICTION $250,000
ACTUAL PRICE $300,000

The prediction is not equal to the actual price.

The training process uses this difference to determine how the model should adjust its learned parameters.

Simple way to remember:

Predict → Compare → Adjust → Repeat.

05

What Does the Model Actually Learn?

A beginner may think that the model simply memorizes the training examples.

That is not the goal.

The model tries to learn patterns or relationships that can also be useful when it receives new data.

For example, while learning house prices, it may learn that house size is related to price and that other features also influence the prediction.

MEMORIZATION Remember every example

This does not necessarily help with a new house the model has never seen.

LEARNING PATTERNS Learn useful relationships

The goal is to use learned patterns to predict new examples.

06

Training With Many Examples

A model normally learns from many training examples, not just one.

EXAMPLE 1 House → $200,000
EXAMPLE 2 House → $300,000
EXAMPLE 3 House → $400,000
EXAMPLE 4 House → $350,000

By looking at many examples, the model can learn broader patterns in the dataset.

This is one reason why useful and representative training data matters.

07

Training Is Different From Making Predictions

Training and prediction are two different stages.

TRAINING Model learns

The model uses training data and adjusts its parameters to learn patterns.

PREDICTION Model uses what it learned

The trained model receives new input and produces an answer.

Training Data Training Trained Model New Data Prediction
08

Example: Spam Detection

The same idea works for classification.

Suppose we want a model to detect spam emails.

TRAINING EXAMPLES Emails + Spam / Not Spam
TRAINING Learn patterns
TRAINED MODEL Can classify new emails

The model can learn patterns that frequently appear in spam emails.

Later, when a new email arrives, the trained model can use what it learned to predict whether the email is spam.

09

Training Does Not Guarantee a Good Model

A model can successfully complete training and still perform badly on new data.

This is important because the real goal is not simply to perform well on the training examples.

The model should learn patterns that generalize to data it has not seen before.

Important:

"The model trained successfully" does not mean "the model is accurate."

We therefore need a separate evaluation stage to measure how well the trained model performs.

KEY IDEA

Training Is How the Model Learns From Examples.

The model receives training data, makes predictions, compares them with known answers, and adjusts its learned parameters. This process repeats so the model can learn useful patterns.

QUICK CHECK

What Happens During Training?

Suppose you give a model 10,000 labelled examples of emails marked as Spam or Not Spam.

What is the model trying to do during training?

Answer

The model studies the examples and learns patterns that help it distinguish Spam from Not Spam.

It adjusts its learned parameters based on the difference between its predictions and the known answers.

NEXT TOPIC

Making Predictions

The model has learned from training data. Now we will see how a trained model uses what it learned to make predictions on new data.