TL;DR

  1. Regularization minimizes the regularized risk with a regularizer that measures how “complex” is. It controls the size of the function class implicitly: a large means a solution in a small class . For consistency, let slowly.
  2. Least squares : if , is unique. Otherwise with the generalized inverse, and every with is also a solution: all agree on the training points but not on test points.
  3. Ridge regression has the unique solution for every . Via the SVD it shrinks the directions with small singular values (mostly noise) the most.
  4. is -strongly convex, so ridge (with a convex -Lipschitz loss) is uniformly stable with : regularization implies stability (Lecture 4).
  5. Lasso : is the convex norm closest to the (NP-hard) count , and its corners give sparse solutions. No closed form.
  6. Rates (fixed design, excess risk): OLS (fast rate, bad in ); ridge ; lasso ; for -sparse . Sparsity turns the dependence on into .

Exam relevance

Neither the first exam nor the mock asked about this lecture directly, so it is a candidate for new tasks in the retake. Likely formats:

  • Multiple choice: effect of on bias, variance, approximation and estimation error; why the lasso is sparse and ridge is not; which norms are convex; which rate belongs to which regularizer.
  • Computations: ridge and lasso by hand for an orthogonal design (task), the closed form of ridge for small data.
  • Selecting rates (task type 4 of the real exam): which regularizer has the best bound for given , , (task).
  • Stability rates (task type 7): how fast may go to 0 so that the stability bound still vanishes (task).
  • Sheet 6: normal equations via orthogonality, over- and underdetermined regime, minimum norm interpolant, ridge as OLS on an augmented system, why gives sparse solutions.
  • Everything in one go: the cheat sheet with two full integration tasks at the end of this note.

Overview: 1. The principle of regularization, 2. Recap: linear least squares, 3. Ridge regression, 4. Tikhonov regularization leads to stability, 5. Lasso and sparsity, 6. Theoretical results for the different regularizers.

Explicit regularization

The principle of regularization

Slides 3-7

(Literature: Shalev-Shwartz and Ben-David, Understanding Machine Learning, Sec. 13.)

  • Training set of points in the standard setup, a very large space of functions (say all real-valued differentiable functions), a loss with empirical and true risk and .

Regularizer and regularized risk

A regularizer measures how “complex” a function is. Examples: = polynomials, = degree of ; = differentiable functions, = maximal slope. The regularized risk is

with the regularization constant . Choose to minimize the regularized risk on the training data.

Why it makes sense

  • If a “simple” function fits the data reasonably well, choose it. If all simple functions have a very high empirical risk, choose a more complex one.
  • SLT (Lecture 3) says: control the size of the function class. In practice this is difficult to do explicitly; regularization does it implicitly, because spaces of simple functions have smaller capacity.
  • Nice side effects: the solution may become unique, the optimization problem may become easier, and the algorithm may become stable, with better generalization guarantees.

What can we choose as a regularizer?

Slides 8-10

Regularizers enforce properties that are hard to control otherwise, such as sparsity or interpretability. takes the parameters of the function as input and returns a real number that measures the property (the smaller the better, since we minimize); to use gradient methods it should be differentiable.

The trade-off: nested function spaces

Consider , nested in .

  • small ⇝ the solution lies in with large: a rich class, small approximation error, large estimation error, risk of overfitting.
  • large ⇝ the solution lies in with small: a poor class, large approximation error, small estimation error, risk of underfitting.
  • is plain ERM over .

But we changed the objective!

Slides 11-12

Regularization does change the objective we optimize. So what about consistency? The idea:

  • choose a huge function class that definitely contains the Bayes classifier;
  • while is small, use a large regularization constant (do not overfit with a complex function);
  • as grows, slowly decrease : we need (and can afford) more complex functions, and still prevent overfitting;
  • as , (at a rate to be determined): in the infinite-sample limit we essentially do not regularize and pick the best function in , the Bayes classifier.

To prove consistency one has to show that this framework works, i.e. converges to . (The stability argument below gives one way.)

Recap: linear least squares regression

Linear setup and concise notation

Slides 13-19

(Literature: Shalev-Shwartz and Ben-David Sec. 9, Bach Sec. 3.)

Training data with and . We look for the best linear function (weights , offset or intercept ) under the squared loss:

Matrix notation

Stack the inputs as rows of the design matrix ( = -th coordinate of point ), the outputs in , the weights in . Then .

Getting rid of : append a column of ones to and to : , . Then , and the problem becomes .

From now on (without loss of generality, dropping the tildes): .

Proposition 1 (least squares is convex)

The least squares problem is a convex optimization problem. (Proof: exercise. The Hessian is positive semi-definite.)

Solution in the full rank case

Slides 20-21

Theorem 2 (solution, case )

If has rank , the solution of linear least squares is

Mini example

Three points : , , , no intercept, . , , so .

Generalized inverse and the general case

Slides 22-25

Moore-Penrose generalized inverse

A symmetric with eigenvalues and eigenvectors has the spectral decomposition . If all , . If is not of full rank, the generalized inverse is

Intuitively, the inverse of restricted to the subspace orthogonal to its nullspace. In general , but and ; if is invertible, .

Theorem 3 (solution, case )

  1. A solution of linear least squares is .
  2. It is not unique. But any two solutions agree on the training data: for all .

On test points the solutions disagree. Which one to prefer? One idea is regularization (below); another is the minimum norm solution (Sheet 6, Lecture 8).

Relationship between n and d

Slides 26-29

The linear system has equations and unknowns, independently of . Either the solution is unique () or there are many (); a solution always exists, however large is. Informally, is the number of parameters, the number of constraints.

  • : harmless. Many points in a low-dimensional space; linear functions are not very flexible and we tend not to overfit (sometimes we underfit). This is what classical statistics has treated for a century.
  • : not quite as harmless. Few points in a high-dimensional space make linear functions very powerful: the function class is too large, which often leads to overfitting. But sometimes “benign overfitting” takes place, particularly in linear regression: the inductive bias of the algorithm makes it harmless (Lecture 8). Many surprising things happen for (high-dimensional statistics: Wainwright; Bühlmann and van de Geer).

Ridge regression (Tikhonov regularization)

Idea and problem

Slides 30-32

(Literature: Bach Sec. 3.6, Shalev-Shwartz and Ben-David Sec. 13.1, Hastie, Tibshirani and Friedman Sec. 3.4.3.) Two goals:

  1. a unique solution, whatever the rank of the design matrix (numerical stability);
  2. small coefficients: in plain least squares the can become very large, which gives a high variance of the results.

Ridge regression

With the regularizer and :

Solution of ridge regression

Slides 33-35

Theorem 4 (solution of ridge regression)

The matrix is invertible for every , so the solution always exists and is unique.

Mini example (the data from above)

Points , , , , : instead of . The coefficient is shrunk towards 0.

Memory aid

Ridge adds to every eigenvalue: the matrix is always invertible, and directions with small eigenvalues (mostly noise) are shrunk the most.

Choice of the parameter λ

Slides 36-38

Question: what is the role of , and what happens to the estimation and approximation error if it is high or low? Larger gives less complex functions: bias goes up, variance goes down.

Fits of a sine function for three values of lambda: strong regularization gives flat fits with low variance, weak regularization wiggly fits with high variance
Slide 37 (from Bishop's book): left, fits on many data sets for decreasing regularization (ln λ = 2.6, −0.31, −2.4); right, the true curve (green) and the average fit (red).
Bias squared increases with ln lambda, variance decreases, the test error has a minimum in between
Slide 38: bias², variance and test error against ln λ.

(*) Ridge regression as a shrinkage method

Slides 39-42

With the singular value decomposition (singular values ), plugging into the formula gives (absorbing the factor into )

  • Without regularization (): .
  • Large : , not much difference.
  • Small : .

Intuition

Regularization “shrinks” the directions of small variance. These are the directions that mainly contain noise, not signal. In statistics such methods are called shrinkage methods.

Stein's paradox and the James-Stein estimator

Estimate the mean of in , , from a single data point . The least squares estimator is . The shrinkage estimator

is better in expected error: . Stein’s paradox (1950s): when estimating at least three parameters jointly, it is better to shrink them.

History and terminology

Slides 43-44

  • Invented by Andrey Tikhonov, 1943, in the context of integral equations (“On the stability of inverse problems”, Doklady Akademii Nauk SSSR): hence Tikhonov regularization.
  • Introduced in statistics by Hoerl and Kennard, “Ridge regression: Biased estimation for nonorthogonal problems”, Technometrics 1970.
  • The original intention was to make the least squares solution more stable and unique: replace by , adding a little “ridge” on the diagonal of the matrix. The regularization interpretation is more recent.

Tikhonov regularization leads to stability

Strong convexity from the regularizer

Slides 45-46

(Literature: Shalev-Shwartz and Ben-David Sec. 13.3; Hardt and Recht p. 113.) A convex loss (for example least squares on a bounded parameter domain) is nice, but convexity does not guarantee a rate for the optimizer, nor stability. For that we need strong convexity (Lecture 4), and the Tikhonov regularizer provides it.

Proposition 5 (the regularizer is strongly convex)

  • is -strongly convex.
  • If is convex and is -strongly convex, then is -strongly convex.

(Proof: exercise. The Hessian of is .)

Regularized ERM is stable

Slides 47-48

Stability of Tikhonov-regularized ERM

ERM with a -strongly convex, -Lipschitz loss has (Theorem 3: ERM is stable from Lecture 4). A convex loss plus is -strongly convex with , so

Trap

Slide 47 writes the gap as . The expected generalization gap in Proposition 1 (gap = average stability) of Lecture 4 is true minus empirical risk, .

Choice of (the trade-off again). The theorem holds for every fixed , but:

  • the stability term , and with it the generalization gap, gets smaller as increases;
  • the empirical risk gets larger as increases, because the objective is less focused on a small empirical risk.

Which value to choose is not obvious. In practice one often uses cross validation; theory gives rules of thumb (see the bounds below).

Task: how fast may lambda go to zero?

Exam-style task: regularization, stability and rates (4 P)

Math: deciding whether a rate goes to 0

Regularized ERM with a convex, -Lipschitz loss bounded by and the regularizer . Use and the stability bound of Lecture 4.

gap → 0?
?

(a) (1 P, easy) Compute for each .

(b) (1.5 P, harder) Fill in both rows of the table.

(c) (1.5 P, transfer) Which choices are candidates for a consistent regularization scheme, and why do you need both rows?

Lasso: least squares with L1-regularization

Sparsity and a naive regularizer

Slides 49-52

(Books: Hastie, Tibshirani and Friedman Sec. 3.4.3; Bishop Sec. 3; Hastie, Tibshirani and Wainwright Sec. 2. Original paper: Tibshirani, “Regression shrinkage and selection via the lasso”, J. Royal Statist. Soc. B, 1996.)

In linear regression it is very desirable to obtain a solution where many coefficients are zero: a sparse solution. Reasons: stability of the solution; computational reasons (with many basis functions we only need to evaluate a few); interpretability.

Naive regularizer for sparsity

directly penalizes the number of non-zero entries. But is a discrete function, and optimizing discrete functions is typically NP hard.

Excursion: p-norms

Slides 53-55

p-norms and the zero-"norm"

For and : .

  • For this is a norm, hence a convex function.
  • For it is not a norm and not convex.
  • For : (with ; the limit is of , not of ). Not a norm (not even homogeneous), but called the zero-norm in the literature.
Unit spheres in the plane for p = 0.5 (star shape), 1 (diamond), 2 (circle) and infinity (square)
Slide 54: unit spheres for p = 0.5, 1, 2 and ∞. For p < 1 the ball is not convex.

Sparsity and the L1-norm

Slides 56-58

is “as close” to the non-convex as possible while still being convex. Does it still tend to give sparse solutions? Yes.

Contour lines of the empirical error touching the L2 ball at a point with both coordinates non-zero, the L1 ball at a corner with w1 = 0, and an Lp ball with p below 1 at a corner
Slide 57: the best solution with ‖w‖ ≤ const. L2: both coordinates non-zero. L1: the contour lines touch at a corner, w₁ = 0 (sparse). Lp with p < 1: even sparser, but not convex any more.

Why L2 is not sparse and L1 is

The -norm puts a particularly large (quadratic) penalty on large coefficients. To avoid it, it is better to have many small non-zero than a couple of large ones and many zeros: rather prevents sparsity. The -norm punishes all weights linearly, so it can afford one large weight if at the same time many small weights disappear.

The picture of slide 57 to play with. Click to move the least squares solution ŵ, shrink the budget t and watch where the error ellipses touch the L2 ball (red) and the L1 diamond (blue). Right: the coefficient paths; lasso coefficients hit exactly 0, ridge coefficients only shrink.

The lasso

Slides 59-62

Lasso

Input space , output , training data , , linear functions, squared loss, regularizer :

The objective is convex (a sum of two convex functions), but there is no closed form solution; it is solved by a standard convex optimization algorithm.

Noisy samples of a periodic function with the Bayes function, the ridge fit and the lasso fit
Slide 61 (figure by Matthias Hein): ridge and lasso fits of a perturbed periodic function.
Training and test error and the fraction of non-zero coefficients for ridge and lasso against the regularization parameter
Slide 60 (figure by Matthias Hein): with growing λ the lasso quickly sets almost all coefficients to 0 (green), ridge keeps all of them non-zero (blue). As the sparsity increases, the test error also increases rapidly.

History. LASSO stands for “least absolute shrinkage and selection operator”, invented by Tibshirani (1996); a short retrospective with literature pointers: Tibshirani, “Regression shrinkage and selection via the lasso: a retrospective”, J. R. Statist. Soc. B (2011).

Memory aid

Lasso = soft threshold: coefficients below (orthogonal design) die, the others shrink by . Ridge only divides, it never kills.

Task: ridge and lasso by hand

Exam-style task: ridge and lasso for an orthogonal design (4 P)

Math: derivatives, also of the absolute value · ℓ1 and ℓ2 norms

Assume the columns of are orthogonal with , and the unregularized least squares solution is . Then (up to a constant) .

(a) (1 P, easy) Show that ridge with gives , and compute it for .

(b) (1.5 P, harder) Show that the lasso with gives the soft thresholding , and compute it for .

(c) (1.5 P, transfer) For which is exactly one lasso coefficient non-zero? Can ridge ever produce a zero coefficient here?

Theoretical results for the different regularizers

Model assumptions: linear model plus noise

Slides 63-65

(Literature: Bach Sec. 3 for least squares without regularization and ridge, Sec. 8 for the lasso. The bounds are stated without proofs.) To make the analysis simpler, we make strong assumptions.

Linear model

Data and a vector with

where the noise variables are independent with and variance . is the design matrix, the output vector, the true and the sample covariance matrix. We minimize for different regularizers.

Fixed vs. random design

  • Fixed design: the points are fixed; we are interested in the loss on these points (closely related to the training error).
  • Random design: the data is random and we are interested in the test error.

Fixed and random design risk

Slides 66-68

Risks

  • Fixed design risk of a fixed : the points are fixed, the labels random:

Like the training error, but with an expectation over the labels; deterministic if is.

  • For an estimate from the training data, is random and we look at : an outer expectation over the training labels (the randomness of ) and an inner one over independent new labels at the same points. The fixed design Bayes risk is the minimum of .
  • Random design risk: , with Bayes risk attained by .

Ordinary least squares

Slides 69-72

Theorem 6 (excess risk, fixed design, no regularization)

Under the linear model and fixed design, and for any

For the OLS estimate (expectation over the labels only):

The bound grows linearly in , so it is only small if .

Proposition 7 (excess risk, random design, no regularization)

For any fixed : (replace by ). If is invertible, the OLS estimate has expected excess risk

Gut feeling: if were identical to , the trace would be and we recover the fixed design bound.

Trap

Slide 71 writes the left side as ; with on the right it is the excess risk (compare Theorem 6: excess risk of OLS, fixed design).

Ridge regression

Slides 73-76

Proposition 8 (excess risk, fixed design, L2 regularization)

The ridge estimator has

For we recover bias 0 and variance as for OLS. Increasing makes the bias large and the variance small.

Proposition 9 (optimally chosen λ)

Setting bias equal to variance and solving for (rule of thumb) gives

For this is : roughly the square root of the OLS bound. It converges more slowly in ( instead of ), but has a milder dependence on the dimension ( instead of ).

Trap

Slides 74 and 76 say “assume is of the form “. With the formulas of Proposition 9 (ridge with the optimal λ) would not give ; the summary table on slide 81 uses , which is consistent with that rate.

Lasso and L0

Slides 77-80

Proposition 10 (excess risk, fixed design, L1 regularization, optimal λ)

Assume with independent Gaussian noise components of mean 0 and variance , and let minimize the lasso objective. For

with probability at least :

describes the sparsity of the true vector: with non-zero components bounded by one, it is at most . The bound essentially scales as .

Theorem 11 (excess risk, fixed design, L0 regularization, optimal λ)

Same noise assumption, , a minimizer of . For :

This scales as .

  • Compared to OLS or ridge, the dependence moved from to : good in high-dimensional spaces.
  • The extra factor is the number of non-zero elements, the intrinsic dimension of the problem. We get an extra compared to OLS with because we do not know which of the coordinates are the relevant ones.

Summary: rates for fixed design

Slides 81-83

Fixed design excess prediction error

Regularization / assumptionRate
none (OLS)
, if
, if is -sparse with bounded entries
, if
  • Rates that scale as are called fast rates, rates that scale as slow rates.
  • OLS has a natural fast rate, but it scales with the full dimension : only useful when .
  • The basic and bounds are slow rates. Fast rates are possible for them too, but need stronger assumptions on the design matrix (low covariance between variables, eigenvalues of ).
  • For and the rate depends only logarithmically on .
  • The bound gives the ideal sparse fast rate , but is not suitable for practice (NP hard).

Task: which regularizer for high dimensions?

Exam-style task: comparing rates (4 P)

Math: logs

Linear model with , training points, features, and a -sparse with entries equal to 1 (so ). Use the rates of the summary table without constants, = natural log ().

(a) (1 P, easy) Evaluate the rate for OLS and for ridge.

(b) (1.5 P, harder) Evaluate the rate for the lasso and for . Which bounds are informative (well below the noise level )?

(c) (1.5 P, transfer) The number of features grows to with everything else fixed. By which factor does each rate change? Which property of the problem makes the lasso work, and what happens if is dense ()?

Summary

OLSRidge ()Lasso ()
regularizernone
solution (full rank), always uniqueno closed form, convexNP hard
orthogonal design (shrink)soft threshold at (select)hard threshold
sparse?nonoyesyes
strongly convex / stablenoyes, not strongly convexno
fixed design rate

Self-Test

Multiple Choice

Cheat sheet and full integration tasks

The two tasks below use every calculation of this lecture once: least squares, ridge and lasso by hand, then the rates of the four regularizers and the choice of . Write your own sheet first, solve the tasks with it next to you, then open the sheet at the bottom and compare. The letters in brackets name the block of the sheet that a subtask needs.

Full integration task: least squares, ridge and lasso by hand (14 P)

Math: derivatives · ℓ1 and ℓ2 norms

Part 1. Three points : , , . Fit without an intercept.

(a) (2 P, block B) Compute the least squares solution.

(b) (3 P, block B) Compute the ridge solution for (objective ). Which gives exactly ?

Part 2. Now has orthogonal columns with , and the least squares solution is .

(c) (2 P, block C) Compute the ridge solution for .

(d) (2 P, block C) Compute the lasso solution for .

(e) (3 P, block C) For which does the lasso keep exactly two coefficients, and from which on is every coefficient 0? Can ridge produce a zero here?

(f) (2 P, block B) A different data set has points and features. Is the least squares solution unique? Is the ridge solution unique? Give the reason.

Full integration task: rates and the choice of lambda (10 P)

Math: logs · deciding whether a rate goes to 0

Linear model with , training points, features and a -sparse with entries equal to 1, so . Use the rates of the summary table without constants and the natural log ().

(a) (3 P, block E) Evaluate the rate for OLS, ridge, lasso and .

(b) (2 P, block E) Which bounds are informative, that is well below the noise level ? Which of the four are fast rates?

(c) (2 P, block E) The sample grows to . By which factor does each rate change?

(d) (3 P, blocks A and D) Regularized ERM has , and the stability bound vanishes iff . For , , and : does the gap vanish, and does go to 0? Which choices are candidates for a consistent scheme?

References