Why does the lasso give coefficients that are exactly zero while ridge does not? When the design is orthonormal (X⊤X=I), 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 X⊤X=I, let z=X⊤y (this is the least-squares solution). The lasso problem ∥y−Xw∥2+λ∥w∥1, where ∥w∥1=∑j∣wj∣, splits into one problem per coordinate: min⁡wj(wj−zj)2+λ∣wj∣. The answer is soft-thresholding, w^j=sign⁡(zj) (∣zj∣−λ/2)+, where (a)+=max⁡(a,0). Ridge gives w^j=zj/(1+λ), which is never exactly zero.

Steps

  1. Expand the loss using X⊤X=I: ∥y−Xw∥2=∥y∥2−2w⊤z+w⊤w. Up to a constant this is ∑j(wj−zj)2, so each wj can be solved for separately.
  2. Solve for wj>0: the derivative is 2(wj−zj)+λ=0, so wj=zj−λ/2. This is positive only if zj>λ/2. In the same way, wj=zj+λ/2 if zj<−λ/2.
  3. Handle wj=0, where ∣wj∣ has a corner and no ordinary derivative. Use the subgradient: at 0, the slope of ∣wj∣ can be any value in [−1,1]. Then wj=0 is optimal when 0∈−2zj+λ[−1,1], i.e. when ∣zj∣≤λ/2. Together this gives the soft-thresholding formula.
  4. Ridge in the same setting: 2(wj−zj)+2λwj=0 gives w^j=zj/(1+λ). It scales every coefficient down by the same factor and reaches zero only if zj=0.
  5. Draw the picture. The region ∥w∥1≤t 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 ∥w∥2≤t is a circle with no corners.

Common mistakes

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, min⁡w∥y−Xw∥2+λ∥w∥2, and, using the singular value decomposition X=UDV⊤, which directions does ridge shrink the most?
Next in Supervised learning: How can you show that k(x,z)=(1+x⊤z)2 on R2 is a valid kernel by finding a feature map ϕ with k(x,z)=ϕ(x)⊤ϕ(z)? What is Mercer's condition, and why does it show that k(x,z)=x⊤z−1 is not a valid kernel?