Lasso Regression
Linear regression with an L1 penalty that can set weights exactly to zero.
The idea
The L1 penalty λ·Σ|w| has a corner at zero, so as λ increases some weights are pushed exactly to zero and drop out of the model. Lasso therefore does feature selection and regression in one step, giving sparse, easy-to-read models.
minimise Σ(y − ŷ)² + λ·Σ|wⱼ|
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- positive weight
- negative weight
- true weight (dashed)
With no penalty the model fits the noise freely: even useless features get a small weight.
- penalty:
- 0
- zero weights:
- 0
Bars are the learned weights; dashed lines are the weights that generated the data. Features 3, 4 and 6 are pure noise.
Step by step
- 1Standardise the features.
- 2Choose λ.
- 3Minimise squared error + λ·Σ|w| (coordinate descent is common).
- 4Keep the features with non-zero weights.
Where it is used
Genomics and text where there are far more features than samples.
Watch out for
With correlated features it tends to pick one arbitrarily.