Validation & Evaluation
Holdout, stratified splits, repeated holdout, bootstrap, 3-way holdout, k-fold, LOO.
Every validation scheme in the course, on one deck. This is where the "why a validation set" and "k-fold vs LOO" answers come from.
Why evaluate at all
Three reasons, in the deck's numbering:
- To estimate generalisation performance — performance on future, unseen data; the training objective is only a proxy.
- To increase predictive performance — tweak the learning algorithm within a hypothesis space, and select the best-performing model.
- To identify the best algorithm for the problem — compare different algorithms on the same footing.

Parameters versus hyperparameters
| Model parameters | Hyperparameters | |
|---|---|---|
| Definition | parameters of the model itself | tuning parameters of the algorithm |
| Learned? | yes — fitted to training data | no — set beforehand |
| Examples | weights $w$ in linear regression | $k$ in k-NN, $C$ and $\gamma$ in SVM, tree depth |

That table answers the practice question about the role of $C$: $C$ is a hyperparameter, selected by validation, never fitted by the optimiser.
The splits, from weakest to strongest
Random subsampling / holdout
Assumption: the dataset is representative of the true population. Split randomly into train and test.
Never judge your model's performance on the training data. It is on the slide in red, and it is the reason every notebook prints test accuracy and not train accuracy.
Holdout's documented problems:
- violation of independence
- changing class proportions
- not suited to limited data
- performance varies a lot with which points happened to be held out
- bias in model evaluation
- lack of variability in the data

Stratified split


The demonstrated failure is vivid: an unstratified 3-class split can produce a test set containing zero instances of one class, which makes the reported accuracy meaningless. train_test_split(..., stratify=y) preserves the class proportions in both parts.
Repeated holdout
Repeat the holdout $k$ times and average. The estimate has less variance and is a better estimate of a random test set. Also called Monte Carlo cross-validation.

Bootstrap
Random sampling with replacement, train set size equal to the original dataset size. Draw $n$ times with replacement, then use whatever was never drawn as the test set (about $1-1/e \approx 36.8\%$ of the data).

3-way holdout
Train / validation / test. The validation set is "a small subset of the training data, used for internal model evaluation, to get a sense of how the model may perform on an unknown test set".

"Why is a validation set necessary? How is it different from the test set?" A validation set exists so that model selection — choosing $k$, $C$, $\gamma$, the number of PCA components — is done on data the model has not been fitted on, while the test set stays untouched until the very end. If you select on the test set, the test set has influenced the model and its reported accuracy is optimistically biased; it is no longer an estimate of generalisation. Concretely: train fits parameters, validation compares candidate hyperparameters/settings, test is used once, for the final unbiased number. In k-fold cross-validation the validation set is replaced by folds, but the test set is still held out.
k-fold cross-validation
> A validation set is no longer needed: the training set is split into $k$ subsets (folds), the model is trained on $k-1$ and validated on the remaining one, rotating. The best model is then used on the test set.

"Every aspect of the learning method that involves use of data — variable selection, model evaluation, etc. — must be cross-validated." If you scale, impute, select features or choose $k$ outside the CV loop, information leaks from the validation fold into training and your estimate is optimistic. This sentence is worth memorising; it is the standard follow-up question.
Leave-one-out (LOO)
$k$ is set to $n$: $n$ models are evaluated, each trained on $n-1$ samples and validated on 1.
| k-fold | LOO | |
|---|---|---|
| Folds | $k$ (typically 5 or 10) | $n$ |
| Models trained | $k$ | $n$ |
| Training size per fold | $(k-1)n/k$ | $n-1$ |
| Bias | slightly pessimistic for small $k$ | nearly unbiased |
| Variance | lower | higher — the $n$ training sets differ by only one point, so the models are almost identical and their errors are highly correlated |
| Cost | $k$ fits | $n$ fits — prohibitive beyond a few thousand samples |
| Stratification | possible | trivially balanced |

"What is cross-validation? k-fold vs LOO?" CV estimates generalisation by rotating which part of the data is held out: partition into $k$ folds, train on $k-1$, validate on the held-out fold, repeat so each fold is validation exactly once, then average the $k$ scores. $k$-fold costs $k$ fits and offers a tunable bias-variance trade-off (small $k$ → more pessimistic bias, less variance; large $k$ → less bias, more variance, more cost). LOO is the $k=n$ extreme: $n$ fits, each on $n-1$ samples, so the bias is nearly zero but the $n$ estimates are highly correlated and the variance and compute are large. Choose $k=5$ or $10$ for a single point estimate — the standard advice — and LOO only for very small datasets.
Metrics, restated
Classification: accuracy, confusion matrix, precision, recall, sensitivity, specificity, F1, ROC, AUC. Regression: MSE, RMSE, MAE, percentage error, max error, $R^2$.

Five reasons given: the training objective is only a proxy; you need a quantitative target; it organises your effort; it measures progress over time; it helps interpret performance.









































