CAB212 · Unit 1: Machine learning foundations
Train/validation/test splits and cross-validation
8 practice questions
Key points
- Test set is used once at the end
- k-fold: k fits, each sample validated once
- Stratify to preserve class ratios
- Fit scalers on training data only
Split data into three parts:
- Training set: fit parameters.
- Validation set: choose hyperparameters and compare models.
- Test set: final unbiased estimate, used once.
A common split is 70/15/15 or 80/10/10. For classification use stratified splits so class proportions are preserved.
k-fold cross-validation: split data into k equal folds; train on k-1 and validate on the remaining fold, rotating k times; average the k scores. Typical k is 5 or 10. Leave-one-out is k = n.
Each sample is used for validation exactly once and for training k-1 times. Cost is k model fits.
Data leakage: any information from validation/test data influencing training (for example fitting a scaler on the full dataset before splitting). It inflates scores.
Exam pitfall: the test set must not be used for tuning; otherwise it becomes a second validation set.
Try two questions
The set used for the final unbiased performance estimate is the:
- Bootstrap set
- Validation set
- Test set
- Training set
Show the answer
C. Test data is held out until the end.
In k-fold cross-validation, how many times is the model trained?
- k-1 times
- Once
- k times
- n squared times
Show the answer
C. One fit per fold.