Back to Supervised Learning

Regularization — L1, L2, Early Stopping

The three techniques that prevent overfitting. When and how to use each. FIND_VIDEO: search 'regularization L1 L2 dropout machine learning' — recommended channel: StatQuest. Aim for 10 min or under.

20 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. Overfitting and VarianceFitting a line to a small training set using Least Squares results in zero residuals but high variance on testing data.
  2. Ridge Core ConceptRidge regression introduces a small amount of bias to the fit, resulting in a significant drop in variance and better long-term predictions.
  3. Ridge Cost FunctionThe Ridge cost function minimizes the sum of squared residuals plus lambda times the slope squared, adding a penalty term.
  4. Sensitivity ReductionThe penalty results in a smaller slope, meaning predictions are less sensitive to changes in the input variable.
  5. Lambda's EffectAs lambda increases, the slope shrinks asymptotically toward zero, making predictions less sensitive to the input variable.
  6. Selecting LambdaCross-validation is used to test various lambda values and determine the one that yields the lowest variance.
  7. General Penalty StructureThe Ridge penalty generally includes all parameters squared except for the y-intercept, which is not scaled by measurements.
  8. Solving Underspecified ModelsRidge regression can solve for parameters even when the number of parameters far exceeds the number of available data points.
PDF notes

Frequently asked questions

Why is the y-intercept excluded from the Ridge penalty?

The y-intercept is not scaled by the measurements, unlike the slope parameters, so it is typically left unpenalized.

How do I choose the best value for lambda?

You must try a range of lambda values and use cross-validation (like ten-fold CV) to find the one that minimizes variance.

Does Ridge Regression work only for linear regression?

No, it can be applied to other models like logistic regression, where it optimizes likelihoods instead of squared residuals.

What is the main trade-off when using Ridge Regression?

You trade a small increase in bias (worse fit to training data) for a significant decrease in variance (better generalization to new data).