Training , Validation and Testing

 

๐Ÿง 1. The Core Idea

When building a machine learning model, the goal is not just to fit the data you have, but to generalize to unseen data.

To ensure this, we split data into three parts:

DatasetPurpose
Training set        Learn patterns (fit the model)
Validation set        Tune model & make decisions
Test set        Final unbiased evaluation

๐Ÿ“˜ 2. Training Set

๐Ÿ”น What it is:

The portion of data used to learn model parameters.

๐Ÿ”น What happens here:

  • Model sees input-output pairs
  • Adjusts weights/parameters to minimize error
  • Example:
    • In linear regression → learns coefficients
    • In neural networks → updates weights via backpropagation

๐Ÿ”น Key point:

The model directly learns from this data

๐Ÿ”น Risk:

  • If overused → overfitting
    • Model memorizes instead of generalizing

๐Ÿ” 3. Validation Set

๐Ÿ”น What it is:

A separate dataset used during training to:

  • Tune hyperparameters
  • Select models
  • Decide when to stop training

๐Ÿ”น What happens here:

You evaluate different choices:

  • Learning rate
  • Number of layers
  • Regularization strength
  • Tree depth (in decision trees)

๐Ÿ”น Example:

You train 5 models with different hyperparameters → pick the one with best validation performance.

๐Ÿ”น Key point:

Validation guides model selection, not learning

๐Ÿ”น Important concept:

Hyperparameters vs Parameters

Type        Learned?Example
Parameters        Yes        Weights in NN
Hyperparameters        No        Learning rate, depth

๐Ÿงช 4. Test Set

๐Ÿ”น What it is:

A completely unseen dataset used only once:
๐Ÿ‘‰ After model is finalized

๐Ÿ”น Purpose:

  • Estimate true generalization performance

๐Ÿ”น Key point:

Test data must NEVER influence training or tuning


⚠️ Why this matters:

If test data is used earlier → data leakage
→ overly optimistic results → poor real-world performance


๐Ÿ“Š 5. Typical Workflow

Dataset → Split → Train / Validation / Test Step 1: Train model on Training set Step 2: Tune using Validation set Step 3: Final evaluation on Test set

๐Ÿ”„ 6. Overfitting vs Underfitting

๐Ÿ”น Overfitting:

  • Excellent training performance
  • Poor validation/test performance

๐Ÿ”น Underfitting:

  • Poor performance everywhere

๐Ÿ”น Ideal:

  • Balanced performance across all sets

๐Ÿ“‰ Visualization Insight

Typically:

Model Complexity    Training Error    Validation Error
Low    High    High
Medium    Low    Lowest
High    Very Low    High (overfitting)

๐Ÿ” 7. Cross-Validation (Important Teaching Point)

Instead of a single validation split:

๐Ÿ“Œ k-Fold Cross-Validation:

  • Split data into k parts
  • Train k times:
    • Each time, one part = validation
    • Others = training

๐Ÿ”น Benefits:

  • Better use of limited data
  • More robust performance estimate

๐Ÿงฉ 8. Practical Data Split Ratios

Common splits:

  • 70 / 15 / 15
  • 80 / 10 / 10
  • 60 / 20 / 20 (for smaller datasets)

๐Ÿง 9. Intuitive Analogy (Good for Teaching)

Think of:

  • Training set → studying material
  • Validation set → practice tests
  • Test set → final exam

๐Ÿ‘‰ You should NOT practice using the final exam!


๐ŸŽฏ 10. Why This is Critical

Proper use of training, validation, and test sets ensures:

✅ Reliable performance estimates
✅ Better model selection
✅ Avoidance of overfitting
✅ Real-world applicability


๐Ÿงพ 11. Summary

SetRoleUsed for
Training        Learning        Fit parameters
Validation        Tuning        Model selection
Test        Evaluation        Final performance

Comments

Popular posts from this blog

Machine Learning PCCST503 Semester5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Machine Learning (ML)

Distinguishing Machine Learning from Traditional Programming