Why does the lasso give coefficients that are exactly zero while ridge does not? When the design is orthonormal (), what is the lasso solution and how does it compare with ridge?
Supervised learning, Regularisation
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.
What's being asked
Whether you can solve a one-variable problem containing an absolute value, and explain sparsity both with algebra and with a picture.
Key idea
With , let (this is the least-squares solution). The lasso problem , where , splits into one problem per coordinate: . The answer is soft-thresholding, , where . Ridge gives , which is never exactly zero.
Steps
- Expand the loss using : . Up to a constant this is , so each can be solved for separately.
- Solve for : the derivative is , so . This is positive only if . In the same way, if .
- Handle , where has a corner and no ordinary derivative. Use the subgradient: at 0, the slope of can be any value in . Then is optimal when , i.e. when . Together this gives the soft-thresholding formula.
- Ridge in the same setting: gives . It scales every coefficient down by the same factor and reaches zero only if .
- Draw the picture. The region is a diamond with corners on the axes. The elliptical contours of the squared loss usually touch it first at a corner, where some coordinates are zero. The ridge region is a circle with no corners.
Common mistakes
- Differentiating at 0 as if it were smooth. You need the subgradient there.
- Getting the threshold off by a factor of 2. It is with this scaling, and for .
- Claiming the lasso picks the right features among correlated ones. It tends to pick one of them arbitrarily; the elastic net handles this better.
How long your answer should be
Half a page with one sketch; about 5 minutes.
Last checked on 4 December 2026.
Read this
Previous in Supervised learning: What is the closed-form solution of ridge regression, , and, using the singular value decomposition , which directions does ridge shrink the most?
Next in Supervised learning: How can you show that on is a valid kernel by finding a feature map with ? What is Mercer's condition, and why does it show that is not a valid kernel?