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:
| Dataset | Purpose |
|---|---|
| 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
๐ 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
| Set | Role | Used for |
|---|---|---|
| Training | Learning | Fit parameters |
| Validation | Tuning | Model selection |
| Test | Evaluation | Final performance |
Comments
Post a Comment