Docsity

Regularization in ML: L1/L2 Penalties, Ridge/Lasso Regression, and Stepwise Regression, Lecture notes of Introduction to Machine Learning

Partial preview of the text

Download Regularization in ML: L1/L2 Penalties, Ridge/Lasso Regression, and Stepwise Regression and more Lecture notes Introduction to Machine Learning in PDF only on Docsity!

Lecture 7: Regularization

TTIC 31020: Introduction to Machine Learning

Instructor: Greg Shakhnarovich

TTI–Chicago

October 11, 2010

Review

Decomposition of expected squared error, for a fixed x 0 :

EX

[

(y 0 − fˆ (x 0 ))^2

]

= (y 0 − F (x 0 ))^2 ︸ ︷︷ ︸ noise

  • (F (x 0 ) − f¯ (x 0 ))^2 ︸ ︷︷ ︸ bias^2
  • EX

[

( fˆ (x 0 ) − f¯ (x 0 ))^2

]

variance

see derivation notes posted on the website

Plan for today

Regularization

  • (^) Shrinkage methods (ridge regression, lasso)
  • Stepwise regression

Sparsity

Model complexity

Previously: define model complexity as a number of parameters

This is a bit too simplistic. Consider feature vector obtained from x:

˜x =

[

1 x − 2 x 2 x x^2 12 x^2

]T

Nominally, linear regression has 6 parameters. But they are clearly not independent.

Generally, we would like to automatically penalize the complexity of the model, in a more sophisticated way.

Idea: look at the behavior of the values of w∗

Description length

Intuition: should penalize not the parameters, but the number of bits required to encode the parameters

With finite set of parameter values, these are equivalent

With “infinite” set, we can limit the effective number of degrees of freedom by restricting the value of the parameters.

Then we have penalized log-likelihood:

w∗^ = argmax w

∑^ N

i=

log p(xi; w) − penalty(w)

Shrinkage methods

Shrinkage methods impose penalty on the size of w

We can measure “size” in a few different ways. Let us start with L 2 norm:

w∗ ridge = argmax w

∑^ N

i=

log p(xi; w) − λ‖w‖^2

This is ridge regression; λ is the regularization parameter.

Note: no averaging of the log-likelihood!

Ridge regression

w∗ ridge = argmin w

∑^ N

i=

yi − w 0 −

∑^ m

j=

wj x( ji)

2

  • λ

∑^ m

j=

w^2 j

Usually do not include w 0 in regularization (why?) Closed form solution:

ŵ ridge∗ =

λI + XT^ X

XT^ y.

Careful: solution not invariant to scaling! Should normalize input before solving.

Lasso regression

The L 1 -penalized log-likelihood under Gaussian noise model:

∑^ N

i=

(yi − wT^ xi)^2 − λ

∑^ m

j=

|wj |

This is still concave (i.e. unique maximum), but unfortunately neither closed-form solution nor gradient descent will do the trick.

  • the objective is not “smooth”.

Why is it called “lasso”?

Optimization for Lasso

Similarly, for Lasso:

min w

∑^ N

i=

yi − w 0 −

∑^ m

j=

wj x( ji)

2

subject to

∑^ m

j=

|wj | ≤ t

Compare shape of the penalty as a function of wj :

wj

(wj )^2

wj

|wj |

Lasso vs. ridge: geomtery of error surfaces

An equivalent formulation for Lp regularization: constrained maximization

wˆ = argmax w: Pmj=1 |wj |p≤β

∑^ N

i=

(yi − wT^ xi)^2.

w 2

w 1

`

w ˆM L

Lasso vs. ridge: geomtery of error surfaces

An equivalent formulation for Lp regularization: constrained maximization

wˆ = argmax w: Pmj=1 |wj |p≤β

∑^ N

i=

(yi − wT^ xi)^2.

w 2

w 1

`

w ˆM L

w^21 + w^22

w ˆridge

Lasso vs. ridge: geomtery of error surfaces

An equivalent formulation for Lp regularization: constrained maximization

wˆ = argmax w: Pmj=1 |wj |p≤β

∑^ N

i=

(yi − wT^ xi)^2.

w 2

w 1

`

w ˆM L

w^21 + w^22

w ˆridge

|w 1 | + |w 2 |

Lasso vs. ridge: geomtery of error surfaces

An equivalent formulation for Lp regularization: constrained maximization

wˆ = argmax w: Pmj=1 |wj |p≤β

∑^ N

i=

(yi − wT^ xi)^2.

w 2

w 1

`

w ˆM L

w^21 + w^22

w ˆridge

|w 1 | + |w 2 |

w ˆlasso (^) With sufficiently large λ, lasso leads to sparsity. Must explicitly solve the above optimization problem – e.g., using Lagrange multipliers.

Lasso vs. ridge: geomtery of error surfaces

An equivalent formulation for Lp regularization: constrained maximization

wˆ = argmax w: Pmj=1 |wj |p≤β

∑^ N

i=

(yi − wT^ xi)^2.

w 2

w 1

`

w ˆM L

w^21 + w^22

w ˆridge

|w 1 | + |w 2 |

w ˆlasso (^) With sufficiently large λ, lasso leads to sparsity. Must explicitly solve the above optimization problem – e.g., using Lagrange multipliers.