Lasso Regularization (L1 Regularization) › Intuition

Michael BrenndoerferApril 19, 20252 min read
Machine Learning from ScratchAll chapters
Part 4 of 9Regression Models
Chapter 35Lasso Regularization (L1 Regularization) › Intuition
Reading section 5 of 11 · Intuition · 2 minSection 5 of 11 · 2 min

Book contents

Section 5 of 11 · 2 min read

Lasso Regularization (L1 Regularization) › IntuitionOne section · Sections in this chapter5 / 11 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Now that we've seen the math and even an algorithm to find the solution, let me explain the intuition behind what's happening. Think of each coefficient βj\beta_j as being in a tug-of-war between two forces

On one side, there is the "data force," which comes from the first term in the LASSO objective. This force encourages βj\beta_j to take on a value that best fits the data, much like gravity pulling the coefficient toward its optimal value based on the relationship between feature jj and the target variable. The stronger this relationship, the stronger the pull of the data force.

On the other side, there is the "penalty force," which is introduced by the regularization term involving λ\lambda. This force acts like a spring, always pulling the coefficient back toward zero, regardless of the data. Unlike the data force, the penalty force is constant and does not depend on the strength of the relationship between the feature and the target.

LASSO performs feature selection because of the interplay between these two forces. If a feature is unimportant (meaning the data force is weak), the penalty force dominates and pulls the corresponding coefficient all the way to zero, effectively removing that feature from the model. Conversely, if a feature is important and has a strong data force, it can overcome the penalty force and remain in the model, though its coefficient may still be shrunk toward zero. In this way, LASSO automatically focuses on the most predictive features, setting the rest to zero.

When the coefficient βj\beta_j is exactly zero, it means that LASSO has determined that the corresponding feature does not contribute enough to the prediction to justify its inclusion in the model. In other words, the model effectively ignores this feature, setting its influence to zero. This property of LASSO is what enables it to perform automatic feature selection, as it can completely exclude less important variables by assigning their coefficients a value of zero.