For a single weight and a number , solve and . Why does this show that L1 regularisation gives sparse solutions and L2 does not?
Foundations, Regularisation
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.
What's being asked
Whether you can back up the “diamond touches the axis” picture with a calculation, using subgradients where has a corner.
Key idea
L1 gives soft-thresholding, , which is exactly zero for every . L2 gives proportional shrinkage, , which is zero only when . “Sparse” means many weights are exactly zero.
Steps
- Explain the set-up. is where the weight would be with no penalty, and is the penalty strength. With (uncorrelated, unit-scale features), lasso and ridge regression split into exactly this 1D problem for each weight.
- L2. Differentiate and set to zero: , so . Every weight shrinks by the same factor, and none becomes exactly zero.
- L1, away from zero. If , the derivative is , so ; this is only valid when . If , then , valid only when .
- L1, at zero. has a corner at 0, so it has no derivative there. Its subgradient (the set of slopes of lines touching from below at 0) is . The optimality condition holds exactly when . So for the whole interval .
- Combine the cases: Small values of are set exactly to zero; this is why the lasso selects features.
- Add the picture. Write the problem as “minimise the loss subject to ”. The L1 ball is a diamond with corners on the axes, and the oval contours of the loss usually first touch it at a corner, where some weights are zero. The L2 ball is round and has no corners.
Common mistakes
- Using as the derivative of at . You need the subgradient .
- Saying L2 makes weights “so small they become zero”. It rescales them and never gives exact zeros.
- Drawing the diamond without saying why touching at a corner is likely: the corners stick out towards the contours.
How long your answer should be
Half a page: the two 1D solutions plus the diamond-and-circle sketch.
Last checked on 4 December 2026.
Read this
- James, Witten, Hastie and Tibshirani, An Introduction to Statistical Learning (ISLR, 2nd ed.): Free PDF. Section 6.2.2, The Lasso (p. 241): 'The Variable Selection Property of the Lasso' (Figure 6.7, diamond against circle) and 'A Simple Special Case for Ridge Regression and the Lasso' (Figure 6.10, soft-thresholding against proportional shrinkage).
- Hastie, Tibshirani and Friedman, The Elements of Statistical Learning (ESL, 2nd ed.): Free PDF. Section 3.4.3 (p. 69), Table 3.4 and Figure 3.11: closed-form ridge and lasso estimators for orthonormal X.
- NPTEL: Introduction to Machine Learning (IIT Madras, Prof. Balaraman Ravindran): Week 2, Shrinkage Methods: covers ridge and lasso penalties and why the L1 penalty gives sparse solutions.
Previous in Foundations: How do you derive the bias–variance decomposition of the expected squared error , where is the model fitted to a random training set?
Next in Foundations: Why is the predictor that minimises the expected squared loss the conditional mean , and why is the classifier that minimises the expected 0-1 loss ?