Key Moments

Stanford CS229 Machine Learning | Spring 2026 | Lecture 6: Dataset Split, ML Advice

Stanford OnlineStanford Online
Education4 min read79 min video
Jul 30, 2026|758 views|28
Save to Pod

Want to know something specific about what's covered?

We've already dissected every moment. Ask and we will deliver (with timestamps).

TL;DR

Models with more parameters than data can generalize well, defying classical bias-variance trade-offs; regularization techniques aim to reduce variance at the cost of slight bias.

Key Insights

1

The classical bias-variance trade-off suggests that increasing model complexity reduces bias but increases variance, leading to a U-shaped test error curve.

2

Modern machine learning models, often vastly overparameterized, can interpolate training data perfectly and still generalize, a phenomenon known as 'double descent', where test error decreases beyond the interpolation threshold.

3

Regularization techniques, like ridge regression, are used to reduce model variance by adding a penalty term, often trading a small increase in bias for a significant reduction in variance.

4

The 'ImageNet-to-ImageNet-v2' study showed that models trained on the original ImageNet dataset maintained their relative performance ranking on a newly constructed, similar dataset, suggesting robustness against adaptive overfitting.

5

Hyperband is a compute-efficient algorithm for hyperparameter optimization that iteratively runs candidate models for increasing durations and prunes the worst performers, allocating more resources to promising configurations.

6

K-fold cross-validation is a classical statistical method for model evaluation that involves splitting the data into multiple folds, training on a subset, and testing on the remaining fold, repeated across all folds to get a more robust estimate of performance.

The fundamental tension: Overfitting and Underfitting

The lecture begins by introducing the core concepts of overfitting and underfitting, which represent a fundamental tension in machine learning. Underfitting occurs when a model is too simple to capture the underlying patterns in the data, leading to high bias. Overfitting, conversely, happens when a model is too complex and learns the training data too well, including its noise, resulting in high variance and poor generalization to new data. These concepts are illustrated with visual examples of fitting lines to quadratic data (underfitting) and high-degree polynomials to noisy data (overfitting), where the model's predictions fluctuate wildly across different training sets.

The bias-variance decomposition

To mathematically formalize overfitting and underfitting, the lecture delves into the bias-variance decomposition. The goal is to understand the expected test error, which can be broken down into three components: irreducible noise (inherent in the data), squared bias (the systematic error of the model's assumptions), and variance (how much the model's predictions change with different training sets). The classical bias-variance trade-off states that as model complexity increases, bias typically decreases, but variance increases. This creates a U-shaped curve for test error, with an optimal model complexity somewhere in the middle that minimizes total error. The mathematical derivation involves fixing a test point and analyzing the expected squared difference between the true value and the model's prediction, averaging over training set draws and test point noise.

Regularization to combat variance

To address the issue of high variance in overfitted models, regularization techniques are introduced. The primary goal of regularization is to reduce variance, even if it slightly increases bias. Ridge regression is presented as a concrete example, which adds an L2 penalty term to the least squares cost function. This penalty shrinks the model's coefficients towards zero, effectively reducing their magnitude and making the model less sensitive to specific training data points. The lecture mathematically shows how this regularization term stabilizes the solution, particularly in ill-conditioned or underdetermined systems where the standard least squares inverse might be unstable or lead to high variance. The strength of this regularization is controlled by a hyperparameter (e.g., 'row' in ridge regression), which itself needs to be tuned.

Modern ML: Double Descent and Robustness

A significant portion of the lecture explores modern perspectives that challenge the classical bias-variance trade-off. The concept of 'double descent' is introduced, which describes a phenomenon where, beyond the interpolation threshold (where models have more parameters than data points and perfectly fit the training set), test error can actually decrease again. This suggests that highly overparameterized models, often used in deep learning, can generalize surprisingly well. The lecture also discusses the 'ImageNet-to-ImageNet-v2' study, which demonstrated that models maintained their relative performance rankings even when tested on a newly constructed dataset, indicating robustness against adaptive overfitting and suggesting that generalization in large models is more profound than classical theory might predict.

Model selection and hyperparameter tuning

Efficiently selecting the best model and tuning its hyperparameters is crucial. The lecture touches upon classical methods like k-fold cross-validation, where the training data is split into multiple folds to iteratively train and validate models, providing a more robust performance estimate without sacrificing too much training data. For compute efficiency, the 'Hyperband' algorithm is presented. Hyperband works by running many candidate configurations (e.g., different hyperparameters or regularization strengths) for a small number of epochs, then discarding the worst performers and allocating more resources to the promising ones, exponentially increasing compute for better models.

Common Questions

The fundamental trade-off in machine learning is between bias and variance. Models that are too simple may have high bias (underfitting), while models that are too complex may have high variance (overfitting), leading to poor generalization.

Topics

Mentioned in this video

More from Stanford Online

View all 106 summaries

Ask anything from this episode.

Save it, chat with it, and connect it to Claude or ChatGPT. Get cited answers from the actual content — and build your own knowledge base of every podcast and video you care about.

Get Started Free