Skip to main content
Feature SelectionMethod Comparison· 3 min read· in Data & Analysis

How the L1 Penalty in Lasso Regression Forces Coefficients to Zero for Feature Selection

By applying an absolute-value penalty to regression coefficients, the Lasso method shrinks less important variables exactly to zero. This geometric constraint allows the algorithm to perform automatic feature selection in high-dimensional datasets where traditional models fail.

By Karim Mansour

Sparsity Advocates 40%Stability Advocates 35%Hybrid Practitioners 25%
Sparsity Advocates
Favor Lasso for its ability to produce highly interpretable, pruned models.
Stability Advocates
Favor Ridge for its mathematical stability and handling of multicollinearity.
Hybrid Practitioners
Favor Elastic Net to balance both trade-offs at the cost of computation.

The competing cases

Lasso (L1 Penalty)

Optimizes for sparsity by forcing coefficients to zero.

Lasso excels in high-dimensional environments where the true underlying model is sparse—meaning only a small fraction of the available features actually drive the outcome. By applying the L1 penalty, it aggressively prunes the dataset, yielding highly interpretable models that require fewer inputs at inference time. However, it struggles with multicollinearity, often dropping correlated variables unpredictably. Fits well when feature selection is the primary goal; does not fit when variables are highly correlated.

Ridge (L2 Penalty)

Optimizes for stability by shrinking coefficients without dropping them.

Ridge regression applies a squared penalty that smoothly shrinks all coefficients toward zero, distributing the weights among correlated features rather than picking a single winner. This makes it highly stable and mathematically well-behaved, often yielding superior predictive accuracy when most variables contribute at least slightly to the outcome. It fails, however, at feature selection, leaving the model just as complex as the raw data. Fits well when all features are believed to be relevant; does not fit when a sparse, interpretable model is required.

Elastic Net (Hybrid)

Balances sparsity and stability by combining both penalties.

By mixing the L1 and L2 penalties, Elastic Net achieves the best of both geometries. It can force coefficients to zero like Lasso, but when it encounters a group of highly correlated variables, the L2 component ensures they are selected or dropped together as a block. This requires tuning an additional hyperparameter (the mixing ratio), which increases computational cost during cross-validation. Fits well when datasets have both high dimensionality and strong internal correlations; does not fit when computational resources for hyperparameter tuning are strictly limited.

In 1996, statistician Robert Tibshirani published a 22-page paper in the Journal of the Royal Statistical Society that fundamentally altered how algorithms process high-dimensional data. By introducing the Least Absolute Shrinkage and Selection Operator (Lasso), Tibshirani provided a mathematical mechanism to not just shrink regression coefficients, but force the multipliers of less important variables exactly to zero.[1][5]

Before this publication, models facing hundreds of variables relied heavily on Ridge regression or stepwise selection. Ridge regression applies an L2 penalty—squaring the coefficients—which shrinks them toward zero to prevent overfitting, but never actually removes them from the equation. A model trained on 1,000 inputs using an L2 penalty still requires all 1,000 inputs to make a single prediction.[4][5]

Lasso replaced the squared L2 penalty with an L1 penalty, which takes the absolute value of the coefficients. This algebraic shift alters the geometry of the optimization problem. When the algorithm minimizes the mean squared error alongside this L1 penalty, the constraint space forms a diamond with sharp corners.[1][3][5]

The sharp corners of the L1 penalty intersect the error contours on the axes, zeroing out variables.

Because the elliptical contours of the error function expand outward from the unpenalized solution, they almost always hit the sharp corners of the L1 diamond first. Those corners lie exactly on the axes of the coordinate system. When the intersection occurs on an axis, the corresponding coefficient is set to precisely 0.[1][5][6]

This geometric intersection gives Lasso its dual capability: it regularizes the model to prevent overfitting while simultaneously performing feature selection. If a dataset contains 50,000 features but only 15 genuinely drive the outcome, the L1 penalty drops the other 49,985 by zeroing out their weights. This allows ordinary least squares to function even when the number of predictors exceeds the number of observations.[2][3][5]

This geometric intersection gives Lasso its dual capability: it regularizes the model to prevent overfitting while simultaneously performing feature selection.

The strength of this penalty is controlled by a tuning parameter, lambda (λ). When λ is set to 0, the penalty vanishes entirely, and the model reverts to standard linear regression. As λ increases, the diamond shrinks, forcing more coefficients to 0 until the model is entirely empty.[3][5]

As the penalty parameter λ increases, Lasso sequentially forces more coefficients to exactly zero.

Data scientists typically use cross-validation to find the optimal λ—the point where the model drops enough noise to generalize well to new data, but retains enough signal to remain accurate. The scikit-learn library in Python implements this optimization efficiently using coordinate descent algorithms, allowing models to converge rapidly even on massive datasets.[2][3]

However, the L1 penalty has a documented mathematical weakness when dealing with highly correlated variables. If three features contain nearly identical information, Lasso tends to arbitrarily select one and zero out the other two. This instability makes the resulting model harder to interpret, as the chosen variable might change entirely if the training data shifts slightly.[2][4]

To resolve this instability, statisticians Hui Zou and Trevor Hastie introduced the Elastic Net in April 2005, publishing their findings across 20 pages. As Zou and Hastie wrote in their introduction, the method "encourages a grouping effect, where strongly correlated predictors tend to be in or out of the model together." By combining both the L1 penalty of Lasso and the L2 penalty of Ridge regression, Elastic Net retains Lasso's ability to drop useless variables while inheriting Ridge's stability.[4]

Elastic Net combines both penalties to achieve feature selection while maintaining grouped variable stability.

The choice between these penalties now forms the foundation of regularized regression. The L1 penalty remains the definitive tool for pure feature selection, isolating the mathematical signal in datasets that are otherwise too wide to parse. The next frontier in regularization involves adapting these exact geometric constraints for deep neural networks, where enforcing sparsity could drastically reduce the billions of parameters currently required for large language models.[2][5][6]

Unsettled ground

  • Which specific correlated variable Lasso will select when faced with a highly collinear group remains mathematically arbitrary.
  • The exact computational cost of tuning the dual hyperparameters in Elastic Net for massive, terabyte-scale datasets.

Sources

Source coverage

6 outlets

3 viewpoints surfaced

Sparsity Advocates 40%Stability Advocates 35%Hybrid Practitioners 25%
  1. [1]Oxford AcademicSparsity Advocates

    Regression Shrinkage and Selection Via the Lasso

    Read on Oxford Academic
  2. [2]MCP AnalyticsHybrid Practitioners

    Lasso Regression: Practical Guide for Data-Driven Decisions

    Read on MCP Analytics
  3. [3]scikit-learnStability Advocates

    1.1.3. Lasso

    Read on scikit-learn
  4. [4]WileyHybrid Practitioners

    Regularization and variable selection via the elastic net

    Read on Wiley
  5. [5]IBMSparsity Advocates

    What is lasso regression?

    Read on IBM
  6. [6]Factlen Editorial TeamHybrid Practitioners

    Synthesis by Factlen editorial team

    Read on Factlen Editorial Team

Comments

Stay informed

Every angle. Every day.

Get Data & Analysis stories with full source coverage and perspective breakdowns delivered to your inbox.