Two Penalties, One Gap

Norms & DistanceHard+30 XP+30

Two Penalties, One Gap

A team is regularizing a linear model with five features. The features happen to be orthonormal — mutually perpendicular, each of length 1 — and for that special case both standard regularizers have an exact closed form, so no iterative solver is needed.

Write zjz_jzj​ for the unpenalized (ordinary least squares) coefficient of feature jjj. Then for penalty strength λ\lambdaλ:

  • Ridge, which penalizes λ∥w∥22\lambda \lVert w \rVert_2^2λ∥w∥22​:
    wjridge=zj1+λw_j^{\text{ridge}} = \frac{z_j}{1 + \lambda}wjridge​=1+λzj​​

  • Lasso, which penalizes λ∥w∥1\lambda \lVert w \rVert_1λ∥w∥1​:
    wjlasso=sign(zj)⋅max⁡(∣zj∣−λ,  0)w_j^{\text{lasso}} = \mathrm{sign}(z_j) \cdot \max\big(\lvert z_j \rvert - \lambda,\; 0\big)wjlasso​=sign(zj​)⋅max(∣zj​∣−λ,0)

The five OLS coefficients are:

Feature jjjzjz_jzj​
1999
2−6-6−6
32.52.52.5
4−1.5-1.5−1.5
5444

The team is not given λ\lambdaλ. Instead they have a sparsity budget: the deployed model must keep exactly two non-zero coefficients, and they use the smallest whole number λ\lambdaλ for which the lasso solution achieves that. The very same λ\lambdaλ is then plugged into the ridge formula, so that the two methods can be compared fairly.

How far apart are the two resulting weight vectors? Compute the Euclidean distance between them:

∥ wridge−wlasso ∥2\big\lVert\, w^{\text{ridge}} - w^{\text{lasso}} \,\big\rVert_2​wridge−wlasso​2​

Give your answer rounded to two decimal places — for example 1.23.

Turn Up the Regularization

Drag the slider. Watch each weight shrink, and see what happens once one actually hits zero.

LowHigh
Credit Score0.52
Income0.38
Occupation0.21
Age0.09
Zip Code0.04

With no regularization, every feature keeps its full weight.

Hints

Solve it to unlock the solution

Once you get it right, the reasoning behind the answer shows up here.