Regularization minimizes the regularized risk Rreg,n(f)=Rn(f)+λΩ(f) with a regularizer Ω that measures how “complex” f is. It controls the size of the function class implicitly: a large λ means a solution in a small class Ft={Ω(f)≤t}. For consistency, let λn→0 slowly.
Least squaresminw∥Y−Xw∥2: if rank(X)=d, w=(XtX)−1XtY is unique. Otherwise w=(XtX)+XtY with the generalized inverse, and every w+v with Xv=0 is also a solution: all agree on the training points but not on test points.
Ridge regressionminwn1∥Y−Xw∥2+λ∥w∥2 has the unique solution wn,λ=(XtX+nλId)−1XtY for every λ>0. Via the SVD it shrinks the directions with small singular values (mostly noise) the most.
λ∥w∥2 is 2λ-strongly convex, so ridge (with a convex L-Lipschitz loss) is uniformly stable with Δsup≤2L2/(λn): regularization implies stability (Lecture 4).
Lassominwn1∥Y−Xw∥22+λ∥w∥1: ∥w∥1 is the convex norm closest to the (NP-hard) count ∥w∥0, and its corners give sparse solutions. No closed form.
Rates (fixed design, excess risk): OLS σ2d/n (fast rate, bad in d); ridge σ∥θ∗∥2d/n; lasso σklogd/n; L0σ2klogd/n for k-sparse θ∗. Sparsity turns the dependence on d into logd.
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 n, d, k (task).
Stability rates (task type 7): how fast λn 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 ℓ1 gives sparse solutions.
Only what you should know by heart in the exam. Click a card for the answer, or press a to go through them as flashcards. For Anki: deck of this lecture.
Regularized risk, and what does λ do?
Answer
Rreg,n(f)=Rn(f)+λΩ(f).
Large λ: small class {Ω(f)≤t}, stable but biased. For consistency let λn→0 slowly.
Least squares solution, with and without full rank?
Answer
rank(X)=d: w=(XtX)−1XtY, unique.
Otherwise w=(XtX)+XtY, and every w+v with Xv=0 is also a solution.
Ridge regression: problem and solution?
Answer
minwn1∥Y−Xw∥2+λ∥w∥2 wn,λ=(XtX+nλId)−1XtY, unique for every λ>0.
Lasso: problem, and how does it differ from ridge?
Answer
minwn1∥Y−Xw∥22+λ∥w∥1, no closed form.
Lasso sets coefficients exactly to 0 (sparse), ridge only shrinks them.
Why does regularization imply stability?
Answer
λ∥w∥2 is 2λ-strongly convex, so with a convex L-Lipschitz loss Δsup≤λn2L2.
Excess risk rates of OLS, ridge, lasso and L0?
Answer
OLS σ2d/n; ridge σ∥θ∗∥2d/n; lasso σklogd/n; L0: σ2klogd/n.
Sparsity turns the dependence on d into logd.
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 n points in the standard setup, F a very large space of functions (say all real-valued differentiable functions), a loss ℓ with empirical and true risk Rn and R.
Regularizer and regularized risk
A regularizerΩ:F→R≥0 measures how “complex” a function is. Examples: F = polynomials, Ω(f) = degree of f; F = differentiable functions, Ω(f) = maximal slope. The regularized risk is
Rreg,n(f):=Rn(f)+λ⋅Ω(f)
with the regularization constantλ>0. Choose f∈F 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 Ft:={f∈F∣Ω(f)≤t}, nested in t.
λsmall ⇝ the solution lies in Ft with t large: a rich class, small approximation error, large estimation error, risk of overfitting.
λlarge ⇝ the solution lies in Ft with t small: a poor class, large approximation error, small estimation error, risk of underfitting.
λ=0 is plain ERM over F.
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 F that definitely contains the Bayes classifier;
while n is small, use a large regularization constant λn (do not overfit with a complex function);
as n grows, slowly decrease λn: we need (and can afford) more complex functions, and still prevent overfitting;
as n→∞, λn→0 (at a rate to be determined): in the infinite-sample limit we essentially do not regularize and pick the best function in F, the Bayes classifier.
To prove consistency one has to show that this framework works, i.e. fn converges to f∗. (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 (Xi,Yi) with Xi∈Rd and Yi∈R. We look for the best linear function f(x)=∑i=1dwix(i)+b (weights wi, offset or intercept b) under the squared loss:
w,bminn1i=1∑n(Yi−f(Xi))2
Matrix notation
Stack the inputs as rows of the design matrixX∈Rn×d (Xik = k-th coordinate of point i), the outputs in Y∈Rn, the weights in w∈Rd. Then f(Xi)=⟨Xi,w⟩+b=(Xw)i+b.
Getting rid of b: append a column of ones to X and b to w: X~=[X1]∈Rn×(d+1), w~=(w1,…,wd,b). Then (X~w~)i=(Xw)i+b, and the problem becomes minw~n1∥Y−X~w~∥2.
From now on (without loss of generality, dropping the tildes): minw∈Rd∥Y−Xw∥2.
Proposition 1 (least squares is convex)
The least squares problem is a convex optimization problem. (Proof: exercise. The Hessian XtX is positive semi-definite.)
Solution in the full rank case
Slides 20-21
Theorem 2 (solution, case rank(X)=d)
If X has rank d, the solution of linear least squares is
w=(XtX)−1XtY
Proof
Objective Obj(w):=21∥Y−Xw∥2, gradient ∇Obj(w)=−Xt(Y−Xw). Setting it to zero gives the normal equationsXtY=(XtX)w. We always have rank(X)=rank(XtX)=rank(XXt), so for rank(X)=d the d×d matrix XtX is invertible and w=(XtX)−1XtY.
Minimum: the Hessian is XtX. It is positive semi-definite (vtXtXv=∥Xv∥2≥0), and because of the rank condition all eigenvalues are >0. □
Mini example
Three points (x,y): (1,1), (2,2), (3,2), no intercept, d=1. XtX=1+4+9=14, XtY=1+4+6=11, so w=11/14≈0.786.
Generalized inverse and the general case
Slides 22-25
Moore-Penrose generalized inverse
A symmetric A∈Rd×d with eigenvalues λi and eigenvectors vi has the spectral decomposition A=∑i=1dλivivit. If all λi=0, A−1=∑iλi1vivit. If A is not of full rank, the generalized inverse is
A+:=i:λi=0∑λi1vivit
Intuitively, the inverse of A restricted to the subspace orthogonal to its nullspace. In general AA+=I, but AA+A=A and A+AA+=A+; if A is invertible, A+=A−1.
Theorem 3 (solution, case rank(X)<d)
A solution of linear least squares is w=(XtX)+XtY.
It is not unique. But any two solutions w1,w2 agree on the training data: ⟨w1,Xi⟩=⟨w2,Xi⟩ for all i.
Proof sketch
As before the normal equations XtY=(XtX)w are necessary; one checks that w=(XtX)+XtY satisfies them (exercise). Non-uniqueness: since rank(X)<d there is v=0 with Xv=0, and w+v is a solution with the same objective value. Predictions on the training points: X(w1+v)=Xw1+Xv=Xw1. □
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 XtY=(XtX)w has d equations and d unknowns, independently of n. Either the solution is unique (rank(XtX)=d) or there are many (rank<d); a solution always exists, however large n is. Informally, d is the number of parameters, n the number of constraints.
d≪n: 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.
d≫n: 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 d≫n (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:
a unique solution, whatever the rank of the design matrix (numerical stability);
small coefficients: in plain least squares the wi can become very large, which gives a high variance of the results.
Ridge regression
With the regularizer Ω(f)=∥w∥2=∑i=1dwi2 and λ>0:
wn,λ:=w∈Rdargminn1∥Y−Xw∥2+λ∥w∥2
Solution of ridge regression
Slides 33-35
Theorem 4 (solution of ridge regression)
wn,λ=(XtX+nλId)−1XtY
The matrix is invertible for every λ>0, so the solution always exists and is unique.
Proof
Obj(w)=n1∥Y−Xw∥2+λ∥w∥2 is convex. Setting the gradient to zero:
∇Obj(w)=−n2Xt(Y−Xw)+2λw=!0⟹(XtX+nλId)wn,λ=XtY
Invertibility.A:=XtX is symmetric positive semi-definite, so all its eigenvalues σ≥0. If Av=σv, then (A+cI)v=(σ+c)v: the eigenvalues of A+cI are σ+c>0 for c=nλ>0. So A+nλI has full rank. □
Mini example (the data from above)
Points (1,1), (2,2), (3,2), n=3, λ=1: w=XtX+nλXtY=14+311≈0.647 instead of 0.786. The coefficient is shrunk towards 0.
Memory aid
Ridge adds nλ 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.
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).Slide 38: bias², variance and test error against ln λ.
(*) Ridge regression as a shrinkage method
Slides 39-42
With the singular value decomposition X=UΣVt (singular values σj), plugging into the formula gives (absorbing the factor n into λ)
wn,λ=Vdiag(σj2+λσj)UtY
Without regularization (λ=0): σj2+0σj=σj1.
Large σj: σj2+λσj≈σj1, not much difference.
Small σj: σj2+λσj≪σj1.
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 N(θ,I) in Rd, d≥3, from a single data point X. The least squares estimator is θ^LS=X. The shrinkage estimator
θ^JS=(1−∥X∥2d−2)X
is better in expected error: E(∥θ−θ^LS∥)≥E(∥θ−θ^JS∥). 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 XtX by XtX+λI, 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)
f(w)=λ∥w∥2 is 2λ-strongly convex.
If g is convex and f is μ-strongly convex, then f+g is μ-strongly convex.
(Proof: exercise. The Hessian of λ∥w∥2 is 2λI.)
Regularized ERM is stable
Slides 47-48
Stability of Tikhonov-regularized ERM
ERM with a μ-strongly convex, L-Lipschitz loss has Δsup≤μn4L2 (Theorem 3: ERM is stable from Lecture 4). A convex loss plus λ∥w∥2 is μ-strongly convex with μ=2λ, so
Δsup≤λn2L2,E(R(fn)−Rn(fn))≤Δsup≤λn2L2
Trap
Slide 47 writes the gap as E(Rn(fn)−R(fn)). The expected generalization gap in Proposition 1 (gap = average stability) of Lecture 4 is true minus empirical risk, E(R(fn)−Rn(fn)).
Choice of λ (the trade-off again). The theorem holds for every fixed λ, but:
the stability term Δsup, and with it the generalization gap, gets smaller as λ increases;
the empirical risk Rn(fn)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)
Regularized ERM with a convex, L-Lipschitz loss bounded by M and the regularizer λn∥w∥2. Use Δsup≤2L2/(λnn) and the stability bound R≤Rn+βn+(2nβn+M)log(1/δ)/(2n) of Lecture 4.
λn
1
n−1/4
n−1/2
n−1
gap → 0?
λn→0?
(a) (1 P, easy) Compute βn for each λn.
(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?
(b) The gap vanishes iff nβn→0 iff λnn→∞: yes for 1 and n−1/4, no for n−1/2 (constant) and n−1 (βn does not even go to 0). λn→0: no for 1, yes for the others. (1.5 P)
(c) Only λn=n−1/4 satisfies both: the gap between training and test risk vanishes (stability) and the regularization disappears asymptotically, so the approximation error can go to 0 (slides 11-12). λn=1 generalizes but stays biased; λn=n−1 removes the bias too quickly to be stable. In general λn→0 with λnn→∞. (1.5 P)
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 wi 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
Ω0(f):=i=1∑d1wi=0
directly penalizes the number of non-zero entries. But Ω0 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 p>0 and w∈Rd: ∥w∥p:=(∑i=1d∣wi∣p)1/p.
For p≥1 this is a norm, hence a convex function.
For 0<p<1 it is not a norm and not convex.
For p=0: ∥w∥0:=limp→0∥w∥pp=∑i∣wi∣0=∑i1wi=0=Ω0(f) (with 00:=0; the limit is of ∥w∥pp, not of ∥w∥p). Not a norm (not even homogeneous), but called the zero-norm in the literature.
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
∥w∥1 is “as close” to the non-convex ∥w∥0 as possible while still being convex. Does it still tend to give sparse solutions? Yes.
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 L2-norm puts a particularly large (quadratic) penalty on large coefficients. To avoid it, it is better to have many small non-zero wi than a couple of large ones and many zeros: L2 rather prevents sparsity. The L1-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 X⊂Rd, output Y=R, training data X∈Rn×d, Y∈Rn, linear functions, squared loss, regularizer Ω(f)=∥w∥1=∑i∣wi∣:
wn,λ:=w∈Rdargminn1∥Y−Xw∥22+λ∥w∥1
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.
Slide 61 (figure by Matthias Hein): ridge and lasso fits of a perturbed periodic function.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 λ/2 (orthogonal design) die, the others shrink by λ/2. Ridge only divides, it never kills.
Task: ridge and lasso by hand
Exam-style task: ridge and lasso for an orthogonal design (4 P)
Assume the columns of X∈Rn×3 are orthogonal with XtX=nI3, and the unregularized least squares solution is w^=n1XtY=(2.0,0.3,−0.8). Then (up to a constant) n1∥Y−Xw∥2=∥w−w^∥2+const.
(a) (1 P, easy) Show that ridge with λ∥w∥2 gives wj=w^j/(1+λ), and compute it for λ=1.
(b) (1.5 P, harder) Show that the lasso with λ∥w∥1 gives the soft thresholdingwj=sign(w^j)max(∣w^j∣−λ/2,0), and compute it for λ=1.
(c) (1.5 P, transfer) For which λ is exactly one lasso coefficient non-zero? Can ridge ever produce a zero coefficient here?
Solution
(a) The objective separates per coordinate: (wj−w^j)2+λwj2, derivative 2(wj−w^j)+2λwj=0, so wj=w^j/(1+λ). For λ=1: (1.0,0.15,−0.4). (1 P)
(b) Per coordinate: (wj−w^j)2+λ∣wj∣. For wj>0 the derivative 2(wj−w^j)+λ=0 gives wj=w^j−λ/2, valid if w^j>λ/2; symmetric for wj<0; otherwise the minimum is at the kink wj=0. For λ=1 (threshold 0.5): (1.5,0,−0.3). (1.5 P)
(c) Coefficient j is non-zero iff ∣w^j∣>λ/2. Exactly one (the first) survives iff 0.8≤λ/2<2, i.e. 1.6≤λ<4. Ridge only divides by 1+λ, so a coefficient is 0 only if w^j=0: ridge shrinks but does not select. (1.5 P)
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 X1,…,Xn∈Rd and a vector θ∗∈Rd with
Yi=⟨Xi,θ∗⟩+εi
where the noise variables εi∈R are independent with E(εi)=0 and variance E(εi2)=σ2. X∈Rn×d is the design matrix, Y the output vector, Σ the true and Σ^=XtX/n the sample covariance matrix. We minimize n1∥Y−Xθ∥22+λΩ(θ) for different regularizers.
Fixed vs. random design
Fixed design: the points X1,…,Xn 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, Rn(θ^) is random and we look at E(Rn(θ^)): an outer expectation over the training labels Yi (the randomness of θ^) and an inner one over independent new labels Y~i at the same points. The fixed design Bayes riskRn∗ is the minimum of Rn(θ).
Random design risk:R(θ)=E(X,Y)(Y−⟨X,θ⟩)2, with Bayes risk R∗ attained by θ∗.
Ordinary least squares
Slides 69-72
Theorem 6 (excess risk, fixed design, no regularization)
Under the linear model and fixed design, Rn∗=σ2 and for any θ
Rn(θ)−Rn∗=∥θ−θ∗∥Σ^2,∥θ∥Σ^2=θ⊤Σ^θ
For the OLS estimate θ^ (expectation over the labels only):
E(Rn(θ^))−Rn∗=nσ2d
The bound grows linearly in d, so it is only small if d≪n.
Proposition 7 (excess risk, random design, no regularization)
For any fixed θ: R(θ)−R∗=∥θ−θ∗∥Σ2 (replace Σ^ by Σ). If Σ^ is invertible, the OLS estimate has expected excess risk
E(R(θ^))−R∗=nσ2E(tr(ΣΣ^−1))
Gut feeling: if Σ^ were identical to Σ, the trace would be tr(Id)=d and we recover the fixed design bound.
Trap
Slide 71 writes the left side as E(R(θ^)); with σ2/n⋅tr(…) on the right it is the excess risk E(R(θ^))−R∗ (compare Theorem 6: excess risk of OLS, fixed design).
For Σ^≈Id this is nσd∥θ∗∥: roughly the square root of the OLS bound. It converges more slowly in n (1/n instead of 1/n), but has a milder dependence on the dimension (d instead of d).
Trap
Slides 74 and 76 say “assume Σ^ is of the form Id/n“. With tr(Id/n)=d/n the formulas of Proposition 9 (ridge with the optimal λ) would not give σd∥θ∗∥/n; the summary table on slide 81 uses Σ^≈Id, which is consistent with that rate.
∥θ∗∥1 describes the sparsity of the true vector: with k non-zero components bounded by one, it is at most k. The bound essentially scales as nkσlogd.
Same noise assumption, ∥θ∗∥0≤k, θ^ a minimizer of n1∥Y−Xθ∥22+λ∥θ∥0. For λ=8σ2log(2d)/n:
E(n1∥X(θ^−θ∗)∥22)≤n16kσ2(1+logd)+n16σ2
This scales as nkσ2logd.
Compared to OLS or ridge, the dependence moved from d to logd: good in high-dimensional spaces.
The extra factor k is the number of non-zero elements, the intrinsic dimension of the problem. We get an extra logd compared to OLS with d=k because we do not know which k of the d coordinates are the relevant ones.
Rates that scale as 1/n are called fast rates, rates that scale as 1/nslow rates.
OLS has a natural fast rate, but it scales with the full dimension d: only useful when d≪n.
The basic L2 and L1 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 L1 and L0 the rate depends only logarithmically on d.
The L0 bound gives the ideal sparse fast rate σ2klogd/n, but L0 is not suitable for practice (NP hard).
Linear model with σ=1, n=104 training points, d=106 features, and a k-sparse θ∗ with k=10 entries equal to 1 (so ∥θ∗∥2=10). Use the rates of the summary table without constants, log = natural log (log106≈13.8).
(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 L0. Which bounds are informative (well below the noise level σ2=1)?
(c) (1.5 P, transfer) The number of features grows to d=1012 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 (k=d)?
Solution
(a) OLS: σ2d/n=106/104=100. Ridge: σ∥θ∗∥d/n=10⋅1000/100≈31.6. Both useless. (1 P)
(b) Lasso: σklogd/n=10⋅3.72/100≈0.37. L0: σ2klogd/n=10⋅13.8/104≈0.014. Only these two are informative. (1.5 P)
(c) OLS grows by 106, ridge by 103, the lasso by 27.6/13.8=2≈1.41, L0 by 2. The lasso profits from sparsity (k≪d): it pays only logd. If θ∗ is dense, k=d and the lasso rate ∼dlogd/n is worse than ridge: sparsity is an assumption, not a free lunch. (1.5 P)
Summary
OLS
Ridge (L2)
Lasso (L1)
L0
regularizer
none
λ∥w∥22
λ∥w∥1
λ∥w∥0
solution
(XtX)−1XtY (full rank)
(XtX+nλI)−1XtY, always unique
no closed form, convex
NP hard
orthogonal design
w^
w^/(1+λ) (shrink)
soft threshold at λ/2 (select)
hard threshold
sparse?
no
no
yes
yes
strongly convex / stable
no
yes, Δsup≤2L2/(λn)
not strongly convex
no
fixed design rate
σ2d/n
σ∥θ∗∥d/n
σklogd/n
σ2klogd/n
Self-Test
Question cards (13)
Define the regularized risk and explain why regularization controls the function class implicitly.
Answer
Rreg,n(f)=Rn(f)+λΩ(f) with a complexity measure Ω. A large λ restricts the solution to a small nested class Ft={Ω(f)≤t}, which has smaller capacity; so we control the class size without fixing it in advance.
What happens to approximation and estimation error when λ is very small or very large?
Answer
Small λ: rich class, small approximation error, large estimation error (overfitting). Large λ: poor class, large approximation error, small estimation error (underfitting).
Regularization changes the objective. How can a regularized method still be consistent?
Answer
Choose a huge class that contains the Bayes classifier and a sequence λn→0 slowly: strong regularization for small n, almost none in the limit. For example with stability: λn→0 and λnn→∞.
Derive the least squares solution in the full rank case.
Answer
The gradient of 21∥Y−Xw∥2 is −Xt(Y−Xw); setting it to 0 gives XtXw=XtY. With rank(X)=d, XtX is invertible: w=(XtX)−1XtY; the Hessian XtX is positive definite, so it is the minimum.
What happens if rank(X)<d?
Answer
w=(XtX)+XtY with the Moore-Penrose inverse is a solution, but w+v with Xv=0 is one too. All solutions give the same predictions on the training points and different ones on test points.
State and prove the ridge solution.
Answer
wn,λ=(XtX+nλI)−1XtY. Gradient −n2Xt(Y−Xw)+2λw=0. The eigenvalues of XtX+nλI are σ+nλ>0, so the matrix is invertible for every λ>0.
Explain ridge regression as a shrinkage method.
Answer
With X=UΣVt: w=Vdiag(σj/(σj2+λ))UtY. Large σj are barely changed (≈1/σj), small σj are shrunk strongly: the directions of small variance, mostly noise.
What is Stein's paradox?
Answer
When estimating the mean of N(θ,I) in d≥3 dimensions from one point X, the shrinkage estimator (1−(d−2)/∥X∥2)X has a smaller expected error than X itself: shrinking jointly estimated parameters helps.
Why does Tikhonov regularization lead to stability, and with which constant?
Answer
λ∥w∥2 is 2λ-strongly convex, and adding it to a convex loss keeps strong convexity. With an L-Lipschitz loss, Theorem 3 (ERM is stable) from Lecture 4 gives Δsup≤4L2/(2λn)=2L2/(λn).
Why is Ω0 a bad regularizer, and what is used instead?
Answer
Ω0=∥w∥0 counts non-zeros: discrete, non-convex, optimization is NP hard. The L1-norm is the closest convex relaxation and still gives sparse solutions.
Why does the lasso give sparse solutions and ridge not?
Answer
Geometrically, the error ellipses touch the L1 ball at a corner, where coordinates are 0; the L2 ball has no corners. Algebraically, L2 penalizes large weights quadratically and prefers many small non-zero weights; L1 penalizes linearly and can set weights exactly to 0 (soft thresholding).
What is the difference between fixed and random design?
Answer
Fixed design treats the inputs Xi as fixed and takes expectations over the labels only (loss on the training points). Random design also takes the expectation over the inputs (test error).
Give the four fixed design rates and explain the role of logd.
Answer
OLS σ2d/n, ridge σ∥θ∗∥d/n, lasso σklogd/n, L0σ2klogd/n. With sparsity, the price for not knowing which k of the d coordinates matter is only logd.
Multiple Choice
Multiple choice (8)
Increasing the regularization constant λ in ridge regression typically
θ∗ is k-sparse and d≫n. Which fixed design rate depends only logarithmically on d?
OLS
ridge
lasso
none of them
Explanation
Lasso σklogd/n (and L0σ2klogd/n). OLS grows like d, ridge like d.
Which rate is called a "fast rate"?
1/n
1/n
logn/n
1/logn
Explanation
Slide 82: rates that scale as 1/n are fast, as 1/n slow. OLS and L0 have fast rates; the basic ridge and lasso bounds are slow.
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 λn. 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)
Part 1. Three points (x,y): (1,1), (2,3), (4,6). Fit f(x)=wx without an intercept.
(a) (2 P, block B) Compute the least squares solution.
(b) (3 P, block B) Compute the ridge solution for λ=1 (objective n1∥Y−Xw∥2+λw2). Which λ gives exactly w=1?
Part 2. Now X∈Rn×4 has orthogonal columns with XtX=nI4, and the least squares solution is w^=(1.5,−0.4,0.9,0.2).
(c) (2 P, block C) Compute the ridge solution for λ=0.5.
(d) (2 P, block C) Compute the lasso solution for λ=1.
(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 n=3 points and d=5 features. Is the least squares solution unique? Is the ridge solution unique? Give the reason.
Solution
(a)XtX=1+4+16=21 and XtY=1+6+24=31, so w=2131≈1.48. (2 P)
(b)w=XtX+nλXtY=21+331=2431≈1.29, shrunk towards 0. Backwards: 21+3λ31=1⟺3λ=10⟺λ=310≈3.33. (3 P)
(c) Ridge divides every coefficient by 1+λ=1.5: (1.0,−0.27,0.6,0.13). (2 P)
(d) The lasso moves every coefficient by λ/2=0.5 towards 0 and sets it to 0 if it does not get that far: (1.0,0,0.4,0). (2 P)
(e) Coefficient j survives iff ∣w^j∣>λ/2. The sizes are 1.5,0.9,0.4,0.2. Exactly two survive iff 0.4≤λ/2<0.9, that is 0.8≤λ<1.8. All are 0 from λ/2≥1.5, that is λ≥3. Ridge only divides, so a coefficient is 0 only if w^j=0: never here. (3 P)
(f)rank(X)≤3<5, so XtX is not invertible and least squares has many solutions. All of them give the same predictions on the three training points. Ridge is unique for every λ>0: the eigenvalues of XtX+nλI are at least nλ>0. (2 P)
Full integration task: rates and the choice of lambda (10 P)
Linear model with σ=1, n=2500 training points, d=104 features and a k-sparse θ∗ with k=5 entries equal to 1, so ∥θ∗∥2=5. Use the rates of the summary table without constants and the natural log (log104≈9.21).
(a) (3 P, block E) Evaluate the rate for OLS, ridge, lasso and L0.
(b) (2 P, block E) Which bounds are informative, that is well below the noise level σ2=1? Which of the four are fast rates?
(c) (2 P, block E) The sample grows to n=104. By which factor does each rate change?
(d) (3 P, blocks A and D) Regularized ERM has βn≤λnn2L2, and the stability bound vanishes iff nβn→0. For λn=1/logn, n−1/3, n−1/2 and n−2/3: does the gap vanish, and does λn go to 0? Which choices are candidates for a consistent scheme?
(b) Only the lasso and L0 are informative. OLS and ridge are above the noise level because d>n. Fast rates (1/n): OLS and L0. Slow rates (1/n): ridge and lasso. (2 P)
(c)n grows by the factor 4. The 1/n rates fall by 4: OLS to 1, L0 to 0.0046. The 1/n rates fall by 2: ridge to 2.24, lasso to 0.15. (2 P)
(d) The gap vanishes iff nβn=λnn2L2→0, that is iff λnn→∞.
λn
λnn
gap → 0?
λn→0?
1/logn
n/logn→∞
yes
yes
n−1/3
n1/6→∞
yes
yes
n−1/2
1
no
yes
n−2/3
n−1/6→0
no
yes
The first two are candidates: the gap between training and true risk vanishes and the regularization disappears in the limit. The last two take the regularization away too quickly to stay stable. (3 P)
Cheat sheet: regularization (6 blocks)
A. What lambda does
You see
It means
λ large
simple function: bias and approximation error up, variance and estimation error down. Underfitting, but stable
λ small
rich class: bias down, variance up. Overfitting
λ=0
plain ERM
λ grows
the training risk grows, the gap between training and true risk shrinks
λn→0 and λnn→∞
a consistent scheme: stable, and the regularization disappears in the limit
B. Least squares and ridge by hand
Solution
Unique?
least squares
w=(XtX)−1XtY
iff rank(X)=d. Never for d>n
ridge, objective n1∥Y−Xw∥2+λ∥w∥2
w=(XtX+nλI)−1XtY
always, for every λ>0
One feature, no intercept: XtX=∑ixi2 and XtY=∑ixiyi, so w=∑xi2∑xiyi and with ridge w=∑xi2+nλ∑xiyi.
Backwards: set the ridge formula equal to the wanted w and solve for λ.
Not unique: all least squares solutions agree on the training points and differ on test points.
C. Orthogonal design
With XtX=nI and the least squares solution w^, every coefficient is treated on its own:
Regularizer
New coefficient
Zero?
ridge λ∥w∥22
1+λw^j
never (only if w^j=0)
lasso λ∥w∥1
sign(w^j)max{∣w^j∣−λ/2,0}
iff ∣w^j∣≤λ/2
Lasso backwards: sort the sizes ∣w^j∣. Exactly m coefficients survive iff λ/2 lies between the (m+1)-th and the m-th largest size.
Why the lasso is sparse. The diamond has corners on the axes, and the contours of the least squares objective usually touch it there. Right: ridge divides a coefficient, the lasso shifts it and sets everything in the flat part to 0.
D. Stability of regularized ERM
λ∥w∥2 is 2λ-strongly convex, and a convex loss plus the regularizer keeps μ=2λ.
With an L-Lipschitz loss: Δsup≤μn4L2=λn2L2.
With λn: the stability bound vanishes iff λnn→∞.
The L1 regularizer is convex but not strongly convex, so this argument does not cover the lasso.
E. Rates for the fixed design
Regularizer
Rate
Type
Depends on d
none (OLS)
nσ2d
fast
linearly
L2
nσ∥θ∗∥2d
slow
d
L1, θ∗k-sparse
nσklogd
slow
logd
L0, ∥θ∗∥0≤k
nσ2klogd
fast
logd
You change
OLS
L2
L1
L0
n times 4
÷4
÷2
÷2
÷4
d squared
times d
times d
times 2
times 2
A bound is informative if it is well below the noise level σ2.
d≪n: OLS is fine. d≫n and sparse: lasso. d≫n and dense (k=d): the lasso rate is worse than ridge.
F. Traps
The ridge formula has nλ, because the objective has the factor n1 in front of the squared error.
The lasso threshold is λ/2, not λ.
Ridge shrinks but never selects. Only the lasso and L0 give exact zeros.
∥w∥p is convex only for p≥1. L0 is not convex and NP hard.
More regularization means a smaller gap but a larger training risk. A small gap alone is not a small risk.
References
All sources cited on the slides, in slide order (15 entries)
Slide
Source
Key point
3
Shalev-Shwartz and Ben-David, Understanding Machine Learning, Sec. 13 (online)
regularization and stability
13
Shalev-Shwartz and Ben-David, Sec. 9; Bach, Learning Theory from First Principles, Sec. 3
linear least squares
29
Wainwright, High-Dimensional Statistics
the case d≫n
29
Bühlmann and van de Geer, Statistics for High-Dimensional Data
the case d≫n
30
Bach Sec. 3.6; Shalev-Shwartz and Ben-David Sec. 13.1; Hastie, Tibshirani and Friedman Sec. 3.4.3
ridge regression
37
Bishop, Pattern Recognition and Machine Learning
example figures for the choice of λ
41
Stein’s paradox; James-Stein estimator
shrinkage beats least squares for d≥3
43
Tikhonov, “On the stability of inverse problems”, Doklady Akademii Nauk SSSR, 1943
origin of Tikhonov regularization
43
Hoerl and Kennard, “Ridge regression: Biased estimation for nonorthogonal problems”, Technometrics, 1970
ridge regression in statistics
45
Shalev-Shwartz and Ben-David Sec. 13.3; Hardt and Recht p. 113 (online)
Tikhonov regularization and stability
49
Hastie, Tibshirani and Friedman Sec. 3.4.3; Bishop Sec. 3; Hastie, Tibshirani and Wainwright Sec. 2
the lasso
49, 62
Tibshirani, “Regression shrinkage and selection via the lasso”, J. Royal Statist. Soc. B, 1996
original lasso paper
60, 61
figures by Matthias Hein
ridge vs. lasso examples
62
Tibshirani, “Regression shrinkage and selection via the lasso: a retrospective”, J. R. Statist. Soc. B, 2011