Cross validation
Cross validation is introduced as a generalization of the simple training/test split idea for evaluating machine learning models.
Udacity · YouTube · 2:41
This 120-second whiteboard lesson introduces cross validation by first showing the limitation of a single train-test split: with a fixed dataset, making the test set larger shrinks the training set. It then presents k-fold cross validation as a structured alternative. The data are partitioned into k equal-size bins; in the worked example, 200 points with give 20 points per bin. For each of k experiments, one bin is held out for testing and the remaining k-1 bins are used for training, after which the k test results are averaged. The clip ends as the speaker begins to mention the additional compute cost. This introductory segment explains the mechanics of k-fold cross validation, highlighting its ability to use all data for both training and testing to yield more accurate assessments. The instructor then sets up a practical comparison between a static train/test split and 10-fold cross validation, asking viewers to evaluate which method is better suited for minimizing training time, minimizing runtime, and maximizing accuracy.
Use the learning inspector for key ideas and moments, or open the reading tabs for the complete notes.
Generated from the video's visuals and explanation; not verbatim speech.
The clip opens with a brief recap of training and test sets, then announces a broader method called cross validation.
To motivate the method, the presenter turns to the difficulty of splitting one fixed dataset into a training part and a testing part.
A long bar is drawn to represent the whole dataset, and the speaker explains that one must decide what fraction becomes testing data and what fraction becomes training data.
The central dilemma is stated explicitly: one wants many points in the training set for good learning, and also many points in the test set for good validation.
Because the total amount of data is fixed, moving any point into the test set removes it from the training set, creating an inherent trade-off.
Cross validation is then introduced as the response to this trade-off.
The basic construction is to partition the dataset into k bins of equal size.
A concrete numerical example follows: with 200 data points and bins, each bin contains 20 points.
The board contrasts the old single-split picture with the new repeated-holdout picture, showing one bin selected as testing while the rest serve as training.
The formal k-fold procedure is then laid out: run k separate learning experiments, each time choosing one of the k subsets as the testing set.
In each experiment, the remaining k-1 bins are combined into the training set, the learning algorithm is trained, and performance is tested on the held-out bin.
The decisive final step is aggregation: after all k experiments, the k testing-set performances are averaged to produce the cross-validation estimate.
The presenter closes this excerpt by noting that the method requires more compute time because the learning experiment is run multiple times.
The video begins by outlining the procedure for k-fold cross validation. The whiteboard displays a dataset divided into ten equal parts, with one part shaded to represent a testing set. The core steps are written out: run k separate learning experiments, where each experiment involves picking a testing set, training the model, and testing it on that specific set. Finally, the test results from all k experiments are averaged.
The speaker emphasizes the primary advantage of this approach: it provides a more accurate assessment of the learning algorithm. Because the folds rotate, every piece of data is eventually used for both training and testing across the k experiments, maximizing data utility.
The scene transitions to a new whiteboard setup to pose a practical question. The instructor writes two column headers: 'TRAIN/TEST' representing a static split methodology, and '10-fold C.V.' representing cross validation.
On the left side, three key evaluation goals for machine learning algorithms are listed: minimizing training time, minimizing run time (the time taken to make predictions after training), and maximizing accuracy.
To facilitate the comparison, the instructor draws a grid of circles at the intersections of the goals and the methods. The viewer is prompted to consider which of the two validation strategies—static train/test or 10-fold cross validation—would be the optimal choice for each of the three distinct goals.
Cross validation is introduced as a generalization of the simple training/test split idea for evaluating machine learning models.
A single split forces a choice of what fraction of the data is used for testing and what fraction for training. The speaker frames this as a dilemma because one wants many points in the training set for the best learning result and also many points in the test set for the best validation.
The video identifies an inherent trade-off in a single split: moving any observation from training to testing reduces the amount of data available for training.
k-fold cross validation partitions the dataset into k equal-size bins, then repeatedly uses one bin as the testing set and the remaining k-1 bins as the training set, runs the learning algorithm, evaluates on the held-out bin, and averages the k test results.
For a dataset of 200 points divided into 10 equal-size bins, each bin contains 20 data points.
After running the k separate experiments, the performance measured on each held-out testing set is averaged to produce the overall cross-validation estimate.
K-fold cross validation is a model evaluation technique that divides the dataset into k equal subsets, or folds. The algorithm is trained and tested k times; in each iteration, a different fold serves as the testing set while the remaining k-1 folds are used for training. The final performance metric is the average of the results from all k experiments. This ensures that all data points are utilized for both training and testing, leading to a more robust and accurate assessment of the model's generalization ability.
When selecting a machine learning algorithm or validation strategy, practitioners typically optimize for three main criteria. First is minimizing training time, which is crucial for rapid prototyping and handling large datasets. Second is minimizing run time, referring to the speed at which the trained model can generate predictions on new data, a vital factor for real-time applications. Third is maximizing accuracy, ensuring the model makes the fewest errors possible on unseen data.
The video sets up a direct comparison between a static train/test split and 10-fold cross validation. A static split partitions the data once into a single training set and a single testing set, which is generally faster but may result in a less reliable performance estimate depending on how the data is divided. In contrast, 10-fold cross validation performs ten separate train/test cycles, rotating the testing set each time. This method uses all data for both training and testing, offering higher accuracy in evaluation at the cost of increased computational time.
Explore conditions, steps and evidence. Supplementary explanations are labeled separately from content shown in the video.
The speaker says the data set is partitioned into k bins of equal size.
The board shows a red lowercase k beside the segmented bar and later writes .
k
Number of equal-size folds or bins used in k-fold cross-validation.
Integer number of partitions; in the worked example .
The speaker gives an example with 200 data points.
The board writes 200 = data set size.
200 = data set size
Total number of data points in the example dataset.
Positive integer count of observations.
The speaker says, if you have 10 bins, what is the number of data points per bin?
The board writes .
In the example, the number of folds is 10.
Specific instance of k.
The speaker answers that each bin has 20 data points.
The board writes 20 inside a small box and then labels the visible bins with 20.
20
Number of data points per fold in the example with 200 total points and 10 folds.
Derived from .
The board shows the text '' circled in red.
The speaker mentions '10-fold cross validation'.
k
The number of folds used in k-fold cross validation.
Positive integer
The speaker writes '10-fold C.V.' on the whiteboard.
C.V.
Abbreviation for Cross Validation.
Text abbreviation
The speaker introduces a method called cross validation as something that slightly generalizes training and test sets.
The title CROSS VALIDATION is written at the top of the board.
Cross validation is presented as a generalization of the simple training/test split idea for evaluating machine learning models.
Used when one wants to evaluate model performance while addressing the tradeoff between training-set size and testing-set size.
The speaker discusses problems with splitting a data set into training and testing data and describes the dilemma of maximizing both sets.
The board writes Problems with splitting into training & testing data, then draws a long bar divided into test and training portions with arrows labeled max.
A single split forces a choice of what fraction of the data is used for testing and what fraction for training. The speaker frames this as a dilemma because one wants many points in the training set for the best learning result and also many points in the test set for the best validation.
Applies to a fixed partition of the dataset into a training subset and a testing subset.
The speaker states there is an inherent trade-off: every data point taken out of the training set into the test set is lost for the training set.
The board circles the boundary between the test and training portions of the bar.
The video identifies an inherent trade-off in a single split: moving any observation from training to testing reduces the amount of data available for training.
Assumes the total dataset size is fixed.
The speaker says the basic idea is to partition the data set into k bins of equal size and run k separate learning experiments.
The board writes k-fold CROSS VALIDATION, shows , and lists Run k seperate learning experiments, pick testing set, train, test on testing set, Average test results from those k experiments.
k-fold cross validation partitions the dataset into k equal-size bins, then repeatedly uses one bin as the testing set and the remaining k-1 bins as the training set, runs the learning algorithm, evaluates on the held-out bin, and averages the k test results.
The dataset is partitioned into k bins of equal size.
Each experiment uses one bin for testing and the remaining k-1 bins for training.
The final reported result is the average over the k experiments.
The speaker gives the example of 200 data points and 10 bins and asks how many data points are in each bin.
The board writes 200 = data set size, , and 20 in a box, then labels the bins with 20.
For a dataset of 200 points divided into 10 equal-size bins, each bin contains 20 data points.
Total dataset size is 200.
Number of bins is 10.
Bins are equal size.
The speaker says the key thing in cross validation is to run this multiple times and then average the different testing set performances.
The board writes Average test results from those k experiments.
After running the k separate experiments, the performance measured on each held-out testing set is averaged to produce the overall cross-validation estimate.
There are k separate test results, one from each fold.
The board lists the steps: 'Run k separate learning experiments', '- pick testing set', '- train', '- test on testing set', and 'Average test results from those k experiments'.
The speaker explains that you run k separate learning experiments and average the test results.
The method involves running k separate learning experiments. For each experiment, a testing set is picked, the model is trained, and then tested on that specific testing set. Finally, the test results from all k experiments are averaged.
The dataset must be divided into k subsets or folds.
The speaker writes 'min. training time', 'min. run time', and 'max accuracy' on the left side of the board.
The speaker lists minimizing training time, minimizing run time after training, and maximizing accuracy as goals.
When assessing machine learning algorithms, common goals include minimizing the time it takes to train the model, minimizing the runtime required to make predictions after training, and maximizing the accuracy of the model's predictions.
The speaker says there is an inherent trade-off because every data point taken out of the training set into the test set is lost for the training set.
With a fixed dataset, increasing the test set by moving points out of the training set necessarily decreases the training set size.
The dataset is split into training and testing subsets.
The total number of data points is fixed.
For every data point moved from training to testing.
The speaker explains that in k-fold cross validation one partitions the data into k equal-size bins, runs k separate learning experiments, uses one bin as testing and the remaining k-1 bins as training, then averages the k test results.
The board lists the procedure: Run k seperate learning experiments; pick testing set; train; test on testing set; Average test results from those k experiments.
k-fold cross validation consists of partitioning the data into k equal-size bins, then for each of k experiments using one bin as the testing set and the remaining k-1 bins as the training set, training and testing, and finally averaging the k test results.
The dataset can be partitioned into k bins of equal size.
Each experiment uses exactly one held-out bin for testing.
For each of the k bins, that bin is used once as the testing set.
The speaker states that the assessment of your learning algorithm will be more accurate.
Using k-fold cross validation provides a more accurate assessment of a learning algorithm compared to a static train/test split.
The algorithm is evaluated using k separate learning experiments.
For any given dataset and learning algorithm.
The speaker says, 'you've kind of used all your data for training and all your data for testing'.
In k-fold cross validation, all available data is utilized for both training and testing across the different folds.
The dataset is partitioned into k folds.
Across all k experiments.
The speaker asks, if you have 200 data points and 10 bins, what is the number of data points per bin? and answers 20.
The board shows 200 = data set size, , and 20 in a box.
The example starts with a dataset containing 200 data points.
Stated directly in the audio and written on the board.
The example uses 10 bins.
Stated directly in the audio and written on the board.
Each bin contains 20 data points.
The speaker states the answer verbally and writes 20 on the board; the underlying arithmetic is 200 divided by 10.
For 200 data points partitioned into 10 equal-size bins, each bin has 20 data points.
The speaker gives an example with 200 data points and 10 bins and says each bin has 20 data points.
The board writes 200 = data set size, , and 20 in a box, then labels the bins with 20.
Given a dataset of 200 data points partitioned into 10 equal-size bins, determine the number of data points per bin.
data set size = 200
bins are equal size
Find the number of data points in each bin.
Use the stated total dataset size.
Given in the example.
Use the stated number of bins.
Given in the example.
Each bin contains 20 data points.
Computed by dividing the total number of points equally among the 10 bins.
20 data points per bin.
The board explicitly writes 20 and labels the bins with 20.
A hand writes the blue title CROSS VALIDATION and underlines it, then writes the black heading Problems with splitting into training & testing data.
Blue title text CROSS VALIDATION
Black heading Problems with splitting into training & testing data
The title is written first.
The problem heading is added below the title.
The board remains a white background with handwritten text.
The visual sequence establishes the topic and motivates the discussion by naming the issue with a single train-test split.
A long red horizontal bar is drawn, the left portion is shaded and labeled test, the right portion is dotted and labeled training, and green arrows labeled max point downward from both regions.
The speaker’s pen circles the boundary between the test and training portions.
Long red bar representing the dataset
Shaded left segment labeled test
Dotted right segment labeled training
Green arrows labeled max
Green circle around the split boundary
The dataset bar is drawn.
The test and training portions are distinguished visually.
Arrows indicate the desire to maximize both portions.
The boundary is circled to emphasize the tradeoff.
The bar represents one fixed dataset.
The two portions together make up the whole bar.
The diagram shows that in a single split, enlarging one subset comes at the expense of the other because the total dataset length is fixed.
The board is cleared except for the title, then a new red bar is divided into equal segments and labeled with k.
The example values 200 = data set size, , and 20 are written, followed by a two-row grid of five visible boxes each labeled 20.
The top-left box is shaded green, is written, and the procedure list is added below.
Only five bins are visibly drawn in each row although the spoken and written example uses .
Red segmented bar
Red lowercase k
Text 200 = data set size
Text
Boxed 20
Two-row grid of visible bins labeled 20
Green-shaded top-left bin
Procedure list in green and black
The single-split diagram is replaced by a partitioned bar.
The example numbers are written.
A grid of equal-size bins is drawn.
One bin is highlighted as the testing set.
The algorithm steps are listed beneath the grid.
All visible bins are labeled with the same size 20.
The highlighted bin is singled out as the testing set while the others remain available for training.
The visual model conveys equal partitioning into folds and the repeated holdout pattern used in k-fold cross-validation.
The whiteboard content abruptly changes from the k-fold diagram to a blank screen with only the title 'CROSS VALIDATION'.
Whiteboard content
The previous diagram and text disappear.
The title 'CROSS VALIDATION' remains at the top.
The instructor clears the board to start a new comparison exercise.
The speaker draws small circles under the 'TRAIN/TEST' and '10-fold C.V.' columns, aligning them with the three goals listed on the left.
Circles
Text labels
Six circles are drawn to form a grid for selecting the best method for each goal.
The text labels for the methods and goals remain unchanged.
A visual matrix is created to map the evaluation goals to the two different validation methodologies.
The speaker says you would like to maximize both sets, but there is an inherent trade-off because every point moved into the test set is lost for training.
The board places max arrows under both test and training and circles the boundary between them.
One may want both the training set and the testing set to be as large as possible at the same time.
With a fixed dataset, a single split cannot maximize both subsets simultaneously; increasing one reduces the other.
The speaker says, So obviously this takes more compute time because you now have to run...
The sentence is cut off before the full consequence is stated.
Cross-validation might be treated as cost-free compared with a single train-test split.
The video explicitly notes that this approach takes more compute time because the learning experiment is run multiple times.
The speaker says cross validation slightly generalizes the earlier training and test set idea, then explains the problem with a single split.
Cross validation is introduced as a generalization of the simpler train-test split framework.
The speaker moves from the general term cross validation to the specific k-fold procedure.
The board changes the heading to k-fold CROSS VALIDATION and lists the k-step procedure.
k-fold cross validation is the specific equal-partition version of cross validation described in the clip.
After describing the inherent trade-off, the speaker says this is where cross validation comes into the picture and then defines partitioning into k bins.
The trade-off in a single split motivates the need for the repeated holdout scheme used in k-fold cross validation.
The speaker says the key thing is to run this multiple times and then average the testing set performances.
The board lists the experiments first and then Average test results from those k experiments.
Averaging the fold-wise test results is part of the k-fold cross-validation procedure.
The speaker writes 'TRAIN/TEST' and '10-fold C.V.' side-by-side as column headers.
The speaker asks to choose between the 'static train test methodology' and '10-fold cross validation'.
The video contrasts the static train/test split methodology with k-fold cross validation as two different approaches to achieve evaluation goals.
The speaker introduces cross validation by name.
The speaker explains the dilemma of splitting data into training and testing sets.
The speaker describes partitioning into k bins and running k experiments.
The speaker works through the 200-point, 10-bin example.
The speaker says this takes more compute time because the experiment is run multiple times.
The sentence is incomplete at the clip boundary.
The board lists the exact steps of the k-fold process.
The board lists the three main goals for algorithm evaluation.
Covered · Opening exchange introduces cross validation as a generalization of training and test sets.
Covered · The speaker explains the dilemma of a single train-test split and the inherent tradeoff.
Covered · The board introduces partitioning into k equal-size bins and works the example.
Covered · The k-fold procedure is written out: run k experiments, choose a testing set, train, test, and average results.
Covered · The speaker begins to note the extra compute cost before the clip ends.
Covered · Explains the steps and benefits of k-fold cross validation.
Covered · Transition and setup for comparing train/test split with 10-fold CV.
Covered · Lists the evaluation goals and sets up a matrix to compare the two methods.
Reviewed English material v1: card/concept_card "Cross validation" starting at 0:09 — Cross validation is introduced as a generalization of the simple training/test split idea for evaluating machine learning models.
Reviewed English material v1: card/concept_card "Training versus testing trade-off" starting at 0:43 — The video identifies an inherent trade-off in a single split: moving any observation from training to testing reduces the amount of data available for training.