blackblack
picture picture

Ch 5.1.1-3: Leave one out and k-Fold Cross-Validation

Lecture 13 - CMSE 381
Michigan State University
::
Dept of Computational Mathematics, Science /span> Engineering
Mon, Feb 16, 2026
Announcements

Last time:

Announcements:

Screenshot of the course schedule forlectures 11 to 20.
Covered in this lecture

Sectionย 1 picture picture

Validation set
Whatโ€™s the problem?

Training Error vs Testing Error

Training Error
Testing Error
Throw-back

Throwback slide showing a figure labeled Fig2-10 from earlier lecture material.

Model tradeoffs

Diagram showing tradeoffs among different statistical models.
Validation set approach

Diagram showing how data are split in the validation set approach.

Example with the auto data

Diagram showing one split of the data
into a training set and a validation set.

Predicting ๐š–๐š™๐š using ๐š‘๐š˜๐š›๐šœ๐šŽ๐š™๐š˜๐š ๐šŽ๐š›:

๐š–๐š™๐š = ฮฒ0 + ฮฒ1๐š‘๐š™ + ฮฒ2๐š‘๐š™2 + โ‹ฏ + ฮฒ p๐š‘๐š™p
Rinse and repeat

Diagram showing the first data split in the validation set approach. Diagram showing the second data
split in the validation set approach. Diagram showing the third data split in the validation set
approach. Diagram showing the fourth data split in the validation set approach. Diagram showing the
fifth data split in the validation set approach.

Again example with auto data

Diagram showing a different training and
validation split, illustrating that the
validation set approach can produce
different results across splits.
Coding example in jupyter notebook

Sectionย 2 picture picture

Leave-One-Out Cross-Validation (LOOCV)
The idea

Diagram showing the first leave-one-out cross-validation split, where one observation is
held out for validation and the rest are used for training. Diagram showing the second
leave-one-out cross-validation split, where a different observation is held out for validation. Diagram showing the third leave-one-out cross-validation split, where a different observation is
held out for validation. Diagram showing the fourth leave-one-out cross-validation split,
where a different observation is held out for validation. Diagram showing the fifth
leave-one-out cross-validation split, where a different observation is held out for validation. โ‹ฎ Diagram showing the final leave-one-out cross-validation split, where the last observation is held out
for validation.
The idea in mathy words

Return the score:

CV(n) = 1 nโˆ‘ i=1nMSE i
Again example with auto data

Figure using the auto data example to
show a fixed result with no randomness
across repeated runs.
Do the LOOCV coding section

LOOCV Pros and Cons

Advantages:

Disadvantages:

TL;DR

Validation set Diagram
showing the first validation
set split. Diagram showing
the second validation set
split. Diagram showing the
third validation set split. Diagram showing the fourth
validation set split. Diagram
showing the fifth validation
set split.
LOO-CV Diagram showing
the first leave-one-out
cross-validation split. Diagram showing the
second leave-one-out
cross-validation split. Diagram showing the third
leave-one-out
cross-validation split. โ‹ฎ Diagram showing the final
leave-one-out
cross-validation split.
LOO-CV Score
CV(n) = 1 nโˆ‘ i=1nMSE i

Sectionย 3 picture picture

k-Fold CV
The idea

Mathy version

Return
CV(k) = 1 kโˆ‘ i=1kMSE i
By hand first!

There are 10 students in the class, and we have data points for each. They have already been randomly permuted below. Write down the training/testing sets for a 3-fold CV
Fold 1
Fold 2
Fold 3
Coding - Building k-fold CV

Pros and Cons

Pros:
Cons:
Comparison

Figure from the auto data
example.

Second figure from the auto
data example.
Validation set
Figure labeled validation set
for comparison.
Next time

Screenshot of the course schedule for lectures 11 to 20.