Lasso keeps the same through-origin rational setup as ridge, but swaps the squared penalty for an absolute-value penalty. The change is exact and visible.

highlighted = computed this step

Same through-origin setup

Use the through-origin model y≈w*x on the exact points (1, 2), (2, 4), and (3, 6). The source sums are sum xy=28 and sum x squared=14.

ywx,xy=28,x2=14y\approx wx,\quad \sum xy=28,\quad \sum x^2=14
Lasso solveExact lambda seven lasso solve.lasso solve, λ=7shown pointx*yx^2p1=(1,2)21p2=(2,4)84p3=(3,6)189Σxy=28; Σx^2=14max(Σxy-λ,0)=21; w=3/2through-origin lasso fit; λ is chosen before the solve; L1 can hit exact zero; NOTconvergence; NOT general feature selection; NOT generalization

Swap the penalty

Ridge uses a squared-weight penalty. Lasso swaps in the absolute-value penalty |w|. The objective convention here is one-half times squared error plus λ|w|, so the threshold formula stays clean.

1/2i(yiwxi)2+λw1/2\sum_i(y_i-wx_i)^2+\lambda |w|
Lasso solveExact lambda seven lasso solve.lasso solve, λ=7shown pointx*yx^2p1=(1,2)21p2=(2,4)84p3=(3,6)189Σxy=28; Σx^2=14max(Σxy-λ,0)=21; w=3/2through-origin lasso fit; λ is chosen before the solve; L1 can hit exact zero; NOTconvergence; NOT general feature selection; NOT generalization

Summary

The data and model are exact rationals. Only the penalty changes: Lasso uses |w|, which can make the final weight exactly zero.

same sums; absolute-value penalty\text{same sums; absolute-value penalty}
Lasso solveExact lambda seven lasso solve.lasso solve, λ=7shown pointx*yx^2p1=(1,2)21p2=(2,4)84p3=(3,6)189Σxy=28; Σx^2=14max(Σxy-λ,0)=21; w=3/2through-origin lasso fit; λ is chosen before the solve; L1 can hit exact zero; NOTconvergence; NOT general feature selection; NOT generalization