4.3 LASSO

DATA 442/642 · Week 4 · PDF · Slides

An L1 penalty that can zero out coordinates.

These notes walk through the lecture slides. The original deck is unchanged; use (slides) on the course hub if you want that PDF.

The figures follow Deisenroth, Faisal, and Ong, Mathematics for Machine Learning, and Theodoridis, Machine Learning: A Bayesian and Optimization Perspective.

1. LASSO

Ridge’s penalty λ∑jθj2 shrinks every coefficient toward zero but never sets one exactly to zero. That is not sparsity.

LASSO (least absolute shrinkage and selection operator) uses an ℓ1 penalty instead:

∑n=1N(yn−θ0−∑j=1lθjxj)2+λ∑j=1l|θj|,

where ∑j=1l|θj| is the ℓ1-norm of (θ1,…,θl)⊤.


2. Geometry

LASSO geometry: ellipse and diamond

The ℓ1 constraint is a diamond. As l grows, that diamond has more corners, so some coefficients land on an axis and become zero. LASSO therefore shrinks and does subset selection.


3. The objective

J(θ)=12N‖𝐲−𝐗θ‖22+λ‖θ‖1.

Squared error plus ℓ1. The ℓ1 term is not differentiable at θj=0, so ordinary gradients are not enough.

A subgradient generalizes the gradient. One subgradient of this J is

g(θ,λ)=−1N𝐗⊤(𝐲−𝐗θ)+λ[sgn(θ1)sgn(θ2)⋮sgn(θl)],

with

sgn(θj)={−1if θj<0,any value in [−1,1]if θj=0,1if θj>0.

Subgradient descent (or a cousin) iterates until θ settles.


4. Comments

  1. LASSO does variance reduction, gives accurate predictions, and is built for variable selection.
  2. A little regularization is usually wise. Ridge is a safe default. Prefer LASSO if you believe only a few features matter.
  3. If the columns of 𝐗 are orthonormal, LASSO has the closed form
θ^j=sgn(θ^LS)(|θ^LS|−λ/2)+.

That is soft thresholding: (·)+ is the positive part (the argument if it is nonnegative, otherwise zero). 4. In the same orthonormal case, ridge is a uniform shrink: θ^R=11+λθ^LS.


5. Computational complexity

A closed form exists only in special cases (orthonormal columns). Otherwise use (sub)gradient descent, especially when there are many features or too many rows for memory.

Soft thresholding is one solver. Another is to approximate ℓ1 by a family of smooth quadratics,

limϵ→0∑i=0lθi2+ϵ.

6. Practice

  1. What does soft thresholding do to a coordinate of the LASSO?

  2. Why is the LASSO objective not differentiable at θj=0?

  3. When would you prefer LASSO to ridge?