Why does L1 regularization produce sparse solutions with exact zeros while L2 does not?

Quick Overview

Asks why an L1 penalty drives some model coefficients to exactly zero while an L2 penalty only shrinks them. Tests the subgradient argument, the one-coordinate closed-form solutions, the constraint-region geometry, and what each penalty means for feature selection.

Why does L1 regularization produce sparse solutions with exact zeros while L2 does not?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Why does L1 regularization produce sparse solutions with exact zeros while L2 does not? ```hint Look near zero Compare the slope of each penalty as a coefficient approaches zero, and ask how strong the loss gradient must be to move a coefficient away from zero in each case. ``` ```hint One coefficient at a time Solve the problem with a single coefficient, minimizing a squared error around some value z plus each penalty, and see for which z the answer is exactly zero. ``` ### What a Strong Answer Covers - Explains the subgradient condition that makes zero optimal under L1, and why the L2 gradient at zero cannot hold a coefficient there. - Gives the one-coordinate (orthonormal design) solutions: soft thresholding for L1 and proportional shrinkage for L2. - Describes the geometric picture of the L1 diamond and the round L2 ball in the constrained form. - States the practical consequence for feature selection, including how correlated features behave. ### Follow-up Questions - With a group of highly correlated features, how does lasso behave, and what does elastic net change? - Why might you see no exact zeros when you train an L1-penalized model with plain SGD? - Lasso shrinks large coefficients by the same amount as small ones. What bias does that cause, and how is it usually reduced? - Why should features be standardized before fitting a lasso?

Overview: Asks why an L1 penalty drives some model coefficients to exactly zero while an L2 penalty only shrinks them. Tests the subgradient argument, the one-coordinate closed-form solutions, the constraint-region geometry, and what each penalty means for feature selection.

General logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

Why does L1 regularization produce sparse solutions with exact zeros while L2 does not?

What a Strong Answer Covers Guidance

  • Explains the subgradient condition that makes zero optimal under L1, and why the L2 gradient at zero cannot hold a coefficient there.
  • Gives the one-coordinate (orthonormal design) solutions: soft thresholding for L1 and proportional shrinkage for L2.
  • Describes the geometric picture of the L1 diamond and the round L2 ball in the constrained form.
  • States the practical consequence for feature selection, including how correlated features behave.

Follow-up Questions Guidance

  • With a group of highly correlated features, how does lasso behave, and what does elastic net change?
  • Why might you see no exact zeros when you train an L1-penalized model with plain SGD?
  • Lasso shrinks large coefficients by the same amount as small ones. What bias does that cause, and how is it usually reduced?
  • Why should features be standardized before fitting a lasso?