2.2.13 · D3Linear & Logistic Regression

Worked examples — L1 (Lasso) regularization

2,013 words9 min readBack to topic

This page hammers the soft-thresholding operator from the parent note against every kind of input it can receive. Read the parent L1 (Lasso) regularization first if the symbols (the OLS coefficient before penalty), (penalty strength), and are new to you — here we assume you know them and we grind through cases.


The scenario matrix

Every cell below is a distinct behaviour of Lasso. The worked examples that follow are tagged with the cell they hit.

# Cell (case class) Trigger condition Expected behaviour
C1 Positive, large shrink down:
C2 Negative, large shrink up:
C3 Inside the band clamp to exactly 0
C4 Boundary knife-edge $ z
C5 Zero input stays 0 for any
C6 No penalty recovers OLS:
C7 Infinite penalty all weights (predict mean)
C8 Vector / feature selection many , one some survive, some deleted
C9 Scaling trap (word problem) features in different units wrong features dropped unless standardized
C10 Exam twist Ridge vs Lasso same Ridge never hits 0; Lasso does

We now cover all ten cells.


The picture that governs everything

Figure — L1 (Lasso) regularization

Worked examples

C1 — Positive, large: plain shrinkage

C2 — Negative, large: sign is preserved

C3 — Inside the band: feature deleted

C4 — Knife-edge: exactly

C5 — Zero input stays zero

C6 — : Lasso becomes OLS

C7 — : everything dies

C8 — The full vector: automatic feature selection

C9 — Word problem: the scaling trap

Figure — L1 (Lasso) regularization

C10 — Exam twist: Ridge vs Lasso on the same small


Active recall

Recall Which matrix cell does

land in, and what is ? C4 (knife-edge). , so . The band is inclusive.

Recall Why does the scaling trap (C9) drop an important feature?

The L1 tax is identical for every coefficient, so a feature whose units force a small coefficient looks cheap to zero out. Standardize first.

Recall On the same

, why does Ridge give but Lasso gives ? Ridge shrinks proportionally (, smooth at 0); Lasso has a dead zone (kink) that clamps small exactly to 0.