Ridge and Lasso Regression
Explore the concepts of Ridge and Lasso regression within supervised learning. Understand how L2 and L1 regularization penalties affect linear model weights, their impact on overfitting, and the geometric intuition behind coefficient shrinkage and feature selection. This lesson helps you compare these methods using visualization techniques and apply them effectively in regression tasks.
We'll cover the following...
In the previous lesson, we saw how regularization helps control overfitting by penalizing large weights and balancing the bias variance trade-off. We also introduced L1 and L2 penalties and discussed their general effects on model behavior. Now, we focus specifically on ridge and lasso regression and examine how these penalties change the solution. Using the same linear model and squared loss, we compare ridge and lasso through their objective functions and visualize their behavior using MSE contours. This geometric perspective helps explain why ridge shrinks all coefficients, while lasso can drive some coefficients exactly to zero.
Ridge and Lasso objectives
Both Ridge and Lasso regression are special forms of regularized linear regression. They use the simplest model type (linear model) and the standard way to measure error (squared loss), differing only in their regularization penalty.
The core model and loss function
Before introducing the penalty, we must define the model that makes a prediction and the loss function that measures the error.
Linear model ()
A linear model assumes the output (, the prediction) is a simple, weighted sum of the inputs (). The goal is to find the best set of weights () that connect the inputs to the output.
- We have training examples, . Each input