The Training Process

What Is the Training Process?

The training process is how a machine learning model learns from data. The model makes predictions, compares them to correct answers, and adjusts itself to improve.

01

Receive input data

02

Make a prediction

03

Compare the prediction to the correct label

04

Calculate the error using the loss function

05

Update internal parameters to reduce the error

06

Repeat for the next batch of examples

Types of Models

Model Examples

Neural Networks — Learn complex patterns from large datasets

Decision Trees — Learn rule-based splits from data

Linear Models — Learn weights for each feature

Ensemble Models — Combine multiple models together

What the Model Learns From

House Price Training Input

Features

  • House size
  • Number of bedrooms
  • Location
  • Year built

Label — Sale price

The Training Cycle in Detail

Step 2 — Prediction

Sample 1: Model predicts $250,000

Sample 2: Model predicts $400,000

Step 3 — Compare to Label

Predicted: $250,000 | Actual: $400,000

Predicted: $400,000 | Actual: $550,000

Step 4 — Calculate Error

$250,000 − $400,000 = −$150,000 error

Goal — Minimize this error over many training steps

The Loss Function

The loss function measures how wrong the model's predictions are. The goal of training is to minimize the loss.

Regression Loss Functions
  • Mean Squared Error (MSE)
  • Mean Absolute Error (MAE)
Classification Loss Functions
  • Binary Cross-Entropy (two classes)
  • Categorical Cross-Entropy (many classes)

Parameters — Weights and Biases

Parameters are the internal values the model adjusts during training to improve its predictions.

Weight Meaning

High weight for "Size" — Model learned size is important for price

Low weight for "Street number" — Model learned street number is not important

Linear Model Example

Price = (Weight_Size × Size) + (Weight_Location × Location) + Bias

The model adjusts each weight and the bias during training.

Epochs

An epoch is one full pass through the entire training dataset. Training usually requires many epochs.

Epoch Progress Example

Epoch 1 — Accuracy: 60%

Epoch 10 — Accuracy: 78%

Epoch 50 — Accuracy: 91%

Accuracy improves with each epoch, though gains slow as the model converges.

Batches

A batch is a small group of examples processed together before updating parameters.

Batch Example

Dataset: 10,000 examples

Batch size: 100

10,000 / 100 = 100 batches per epoch

Why Batches
  • Processing the full dataset at once may require too much memory
  • Frequent parameter updates help the model learn faster
  • Batches introduce randomness that can help avoid poor local minima

Learning Rate

The learning rate controls how large each parameter update is. It is one of the most important hyperparameters in training.

Too High

Parameters change too much each step.

Training may be unstable or fail to converge.

Too Low

Parameters change too slowly.

Training takes very long to complete.

Gradient Descent

01

Calculate the current loss

02

Calculate the gradient — direction of steepest increase in loss

03

Move in the opposite direction of the gradient

04

Update parameters by learning rate × gradient

The goal is to reach the minimum of the loss function — where predictions are most accurate.

Types of Training

Supervised Learning

Model receives labeled examples. Learns to predict the label from features.

Example — Email → Spam or Not Spam

Unsupervised Learning

Model receives data without labels. Discovers patterns and structure on its own.

Example — Customer data with no predefined groups

Reinforcement Learning

Model receives rewards or penalties. Learns through trial and error.

Example — Game AI: +10 for winning, −5 for losing

Training Accuracy Warning

Example

Training accuracy: 95%

This might look good, but it could mean the model memorized training examples rather than learning real patterns.

Always check validation accuracy to confirm generalization

Overfitting and Underfitting

Overfitting

Training: 99% | Validation: 72%

Causes: Model too complex, dataset too small, too many epochs

Underfitting

Training: 58% | Validation: 56%

Causes: Model too simple, too few features, insufficient training

Early Stopping

Early Stopping Example

Epoch 5 — Validation accuracy: 88%

Epoch 10 — Validation accuracy: 91% ← Best

Epoch 15 — Validation accuracy: 89% ← Getting worse

Stop at Epoch 10 and save that version of the model

Hyperparameters

Common Hyperparameters
  • Learning rate
  • Batch size
  • Number of epochs
  • Model architecture
  • Dropout rate
  • Regularization strength

Regularization

Regularization Types

L1 Regularization — Encourages some weights to be exactly zero (feature selection)

L2 Regularization — Encourages weights to be small but non-zero

Dropout — Randomly removes neurons during training to prevent over-reliance on specific paths

Training Time Factors

What Affects Training Time
  • Dataset size — more data takes longer
  • Model complexity — more parameters takes longer
  • Batch size — smaller batches mean more updates per epoch
  • Number of epochs — more epochs take longer
  • Hardware — GPUs train much faster than CPUs

Good Training Data Qualities

Requirements
  • Large enough to learn reliable patterns
  • Diverse and representative of real-world examples
  • Accurate and consistent labels
  • Properly cleaned and preprocessed

Real-World Examples

Spam Detection

7,000 labeled emails | 50 epochs

Training accuracy: 95% | Validation accuracy: 93%

House Price Prediction

Features: Size, bedrooms, location, year | 30 epochs

Training MAE: $18,000 | Validation MAE: $21,000

Image Classification — Epoch by Epoch

Epoch 1: 45% | Epoch 5: 71% | Epoch 10: 83% | Epoch 20: 91%

Training vs Memorization

Good Training

Validation accuracy ≈ Training accuracy

Model generalizes to new data

Has learned real patterns

Memorization (Overfitting)

Validation accuracy much lower than training

Model only works on training data

Has learned noise, not real patterns

Common Problems

Training Problems and Causes

Loss not decreasing — Learning rate may be too low, or data has problems

Loss oscillating — Learning rate may be too high

Training stalls early — Model may need more capacity or better features

Overfitting — Model needs regularization or more data

Ways to Improve Training

Improvements
  • Use more or better quality data
  • Tune the learning rate
  • Add regularization to reduce overfitting
  • Increase model complexity if underfitting
  • Use early stopping to prevent overfitting
  • Clean and preprocess data more carefully

Key Takeaways

Summary
  • The training process involves making predictions, measuring error, and updating parameters
  • The loss function measures how wrong the model is
  • Parameters (weights) are what the model adjusts during training
  • The learning rate controls how large each parameter update is
  • Gradient descent guides updates toward the minimum loss
  • Overfitting occurs when training accuracy is much higher than validation accuracy
  • Early stopping, regularization, and good data quality help achieve better training outcomes

Need Help?

Ask the AI if you need help understanding the training cycle, loss functions, learning rate, gradient descent, overfitting, early stopping, or any other part of how machine learning models train.