TL;DR
Many problems ask for a vector that fits some data while staying simple. L1 minimization measures simplicity by the sum of absolute values, , and minimises that sum, either as a penalty or under a constraint. Unlike the squared penalty, it tends to push many entries to exactly zero. The result is a sparse answer that says which few inputs matter.
Where you'll see it: in the lasso for sparse regression, in compressed sensing that reconstructs images from few measurements, and in robust fitting that ignores outliers.
Intuition
Why absolute values make zeros
Suppose you must pick a point on a line, and you want the point that is "small". If smallness is measured by the squared norm, the best point is pulled toward zero smoothly, and rarely lands on it. If smallness is measured by the absolute value of each coordinate, the cost has a sharp corner exactly at zero. Sharp corners are where optimal solutions tend to land, because a sharp corner gives a cheap way to set a coordinate to zero and pay nothing for it.
The picture below shows the soft-thresholding map that this produces, which is the basic step of the lasso.
- soft threshold, λ = 1
- no penalty
Two shapes of penalty
Picture the set of points with in two dimensions. It is a diamond with corners on the axes. The set with is a smooth circle. Now slide a straight line of candidate solutions toward the origin until it just touches the shape. A circle is usually touched on its side, at a point where neither coordinate is zero. A diamond is usually touched at a corner, where one coordinate is exactly zero. The rest of the math makes this precise.
The math
Definitions
For a vector , the L1 norm is
the sum of the absolute values of the entries. Each is one coordinate, and is its distance from zero. The L1 norm is a norm, so it is nonnegative, zero only for the zero vector, and satisfies the triangle inequality.
Given a matrix and a vector , find
This is called basis pursuit. The penalised version, with , is the lasso.
In the constrained form, says the answer must fit the measurements exactly. The objective then chooses, among all exact fits, the one with the smallest total absolute size. In the lasso, trades fit against sparsity: larger gives sparser answers with worse fit.
Convexity
The L1 norm is a convex function. Each is convex, because it is the maximum of the two linear functions and , and a maximum of convex functions is convex. A sum of convex functions is convex. The constraint is linear, so basis pursuit is a convex problem. Every local minimum is therefore global, and efficient algorithms exist.
Reformulation as a linear program
Write each entry as a difference of two nonnegative numbers, with . At the optimum, . Then basis pursuit becomes
The objective and constraints are linear, so this is a linear program. It can be solved with standard tools for linear programming.
The soft-thresholding formula
The one-dimensional lasso problem has a closed form. Minimise over a real , for a fixed and . The absolute value has no derivative at zero, so use the subgradient. The optimality condition is
If , the solution is , because then fits inside . Otherwise . Together:
This is the function in the plot above. With orthonormal feature columns (uncorrelated, unit length), the lasso solution is exactly this rule applied to each least-squares coefficient. In general it is applied coordinate by coordinate inside an iterative solver.
Why the solution is sparse
Basis pursuit always has a solution at a vertex of the feasible region of the linear program above (when a solution exists). Intuitively, the level sets of are diamond-shaped polytopes with corners on the coordinate axes, and a linear constraint generically meets such a shape at a corner. A corner has zeros in all but a few coordinates, so the answer has at most as many nonzero entries as there are constraints. The L2 norm has no corners, so its minimiser generically has no zeros. This contrast is the heart of the lesson.
Worked examples
Find the point on the line with the smallest L1 norm, and compare with the smallest L2 norm.
- Parametrise the line as , so the L1 norm is .
- Try , where . The norm is , which decreases as grows. Its smallest value on this range is at , giving with norm 2.
- For , the norm is , which is worse. For , is negative and the norm is , also worse.
- So the L1 minimiser is . It has a zero, and only one input is used.
- For the L2 norm, the closest point to the origin on the line is the projection of , which is , with squared norm . Both coordinates are nonzero.
- Interpretation: the L1 answer names one input, while the L2 answer spreads weight over both.
Take with penalty , and with the same penalty.
- For : , so .
- For : , so .
- Check the first case with the optimality condition: , with since . It holds.
- Interpretation: the lasso shrinks a strong signal by and removes a weak one entirely. The second case is where sparsity comes from.
Five measurements are . Find the constant that minimises , and compare with minimising .
- Minimising the sum of squares gives the mean: .
- Minimising the sum of absolute deviations gives the median. The middle value of the sorted list is .
- Check: at the sum is . At it is , which is larger.
- Interpretation: the outlier 100 pulls the mean to 22, but it has only a bounded effect on the L1 fit. This is the reason least absolute deviation is used for robust fitting.
Tradeoffs and failure modes
L1 minimization is powerful when its assumptions hold, and it can mislead when they do not.
| Situation | What goes wrong | Better choice |
|---|---|---|
| Features are strongly correlated | The lasso picks one of a correlated group more or less arbitrarily | Elastic net, which mixes the L1 and L2 penalties |
| Solution should be dense (many small effects) | L1 zeroes out real but small effects | L2 regularization, which shrinks everything smoothly |
| Measurements are noisy, not exact | Basis pursuit with exact equality can overfit the noise | The lasso with a tuned , or a constraint with a noise tolerance |
| Large chosen blindly | Too much shrinkage biases the nonzero coefficients toward zero | Choose by cross-validation |
| Very large problems | Generic linear programming solvers can be slow | Iterative methods such as proximal gradient descent with soft-thresholding |
A common mistake is reading the nonzero coefficients of a lasso fit as causal effects. The L1 penalty chooses a sparse set of predictors, but a different sample or a correlated predictor can produce a different set.
History
Least absolute deviation fitting is older than the L2 method. Pierre-Simon Laplace considered it in the late eighteenth century, when he was comparing ways to combine astronomical measurements. It was used again in geophysics in the 1970s, where robustness to outliers in seismic data was valued.
The modern wave started with Robert Tibshirani's lasso in 1996, which applied the L1 penalty to regression to get sparse, interpretable models. Shaobing Chen, David Donoho and Michael Saunders introduced basis pursuit in 1998 for signal decomposition. Around 2004 to 2006, work by Emmanuel Candès, Terence Tao, Justin Romberg and David Donoho showed that a signal can be recovered exactly from far fewer measurements than its length, if it is sparse and the measurements are random enough. That result, compressed sensing, made L1 minimization a standard tool in imaging and signal processing.
Check yourself
QuestionWhy does minimising over a line tend to give a solution with zeros, while minimising does not?Show answer
The level sets of the L1 norm are polytopes with corners on the coordinate axes. A line generically touches such a shape at a corner, where some coordinates are zero. The L2 level sets are smooth spheres, so the touching point generically has every coordinate nonzero.
QuestionFind the lasso solution for with penalty .Show answer
Since , the formula gives . Check: , with . The condition holds.
QuestionWhy is basis pursuit a convex problem even though the absolute value has a corner at zero?Show answer
Each is the maximum of the linear functions and , so it is convex even with its corner. A sum of convex functions is convex, and the equality constraint is linear, so the whole problem is convex. Its local minima are therefore global.
QuestionA dataset has one outlier far from the rest. Would you expect an L1 fit or an L2 fit of a constant to move more toward the outlier, and why?Show answer
The L2 fit, which is the mean, moves toward the outlier, because squared deviations give it a large weight. The L1 fit, which is the median, moves only a little, because the absolute deviation grows linearly and the median depends only on the ordering of the points. This is why L1 fits are called robust.
Sources
- Lasso (statistics) (Wikipedia)
- Compressed sensing (Wikipedia)
- Boyd and Vandenberghe, Convex Optimization: book page