Top Banner
Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15
21

Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Dec 19, 2015

Download

Documents

Charity Simmons
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Lasso, Support Vector Machines, Generalized

linear modelsKenneth D. Harris

20/5/15

Page 2: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Multiple linear regression

What are you predicting?

Data type Continuous

Dimensionality 1

What are you predicting it from?

Data type Continuous

Dimensionality p

How many data points do you have? Enough

What sort of prediction do you need? Single best guess

What sort of relationship can you assume? Linear

Page 3: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Ridge regression

What are you predicting?

Data type Continuous

Dimensionality 1

What are you predicting it from?

Data type Continuous

Dimensionality p

How many data points do you have? Not enough

What sort of prediction do you need? Single best guess

What sort of relationship can you assume? Linear

Page 4: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Regression as a probability model

What are you predicting?

Data type Continuous

Dimensionality 1

What are you predicting it from?

Data type Continuous

Dimensionality p

How many data points do you have? Not enough

What sort of prediction do you need? Probability distribution

What sort of relationship can you assume? Linear

Page 5: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Different data types

What are you predicting?

Data type Discrete, integer, whatever

Dimensionality 1

What are you predicting it from?

Data type Continuous

Dimensionality p

How many data points do you have? Not enough

What sort of prediction do you need? Single best guess

What sort of relationship can you assume? Linear – nonlinear

Page 6: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Ridge regression

Linear prediction: Loss function:

Both the fit quality and the penalty can be changed.

Fit quality Penalty

Page 7: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

“Regularization path” for ridge regression

http://scikit-learn.org/stable/auto_examples/linear_model/plot_ridge_path.html

Page 8: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Changing the penalty

• is called the “ norm”

• is called the “ norm”

• In general is called the “ norm”

Page 9: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

The LASSO

Loss function:

Fit quality Penalty

Page 10: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

LASSO regularization path

• Most weights are exactly zero• “sparse solution”, selects a

small number of explanatory variables• This can help avoid overfitting

when p>>N• Models are easier to interpret –

but remember there is no proof of causation.• Path is piecewise-linear

http://scikit-learn.org/0.11/auto_examples/linear_model/plot_lasso_lars.html

Page 11: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Elastic net

𝐿=∑𝑖

12

( �̂� 𝑖− 𝑦 𝑖 )2

+12𝜆1|𝐰|1+

12𝜆2|𝐰|2

2

Page 12: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Predicting other types of data

Linear prediction: Loss function:

For ridge regression, . But it could be anything…

Fit quality Penalty

Page 13: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Support vector machine

• For predicting binary data• “Hinge loss” function

f

E

Page 14: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Errors vs. margins

• Margins are the places where • On the correct side of the margin: zero

error. • On the incorrect side: error is distance

from margin.• Penalty term is higher when margins

are close together• SVM balances classifying points

correctly vs having big margins

Page 15: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Generalized linear models

What are you predicting?

Data type Discrete, integer, whatever

Dimensionality 1

What are you predicting it from?

Data type Continuous

Dimensionality p

How many data points do you have? Not enough

What sort of prediction do you need? Probability distribution

What sort of relationship can you assume? Linear – nonlinear

Page 16: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Generalized linear models

Linear prediction: Loss function:

For ridge regression, for a Gaussian distribution with mean .

Page 17: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Generalized linear models

Linear prediction: Loss function:

Where is a probability distribution for with parameter .

Page 18: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Example: logistic regression

𝑝 (𝑦 𝑖 ; 𝑓 𝑖 )={ 1

1+𝑒− 𝑓 𝑖𝑦 𝑖=1

1

1+𝑒 𝑓 𝑖𝑦 𝑖=−1

f

P(y; f)

Page 19: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Logistic regression loss function

𝐸 ( 𝑓 𝑖 , 𝑦 𝑖 )=log𝑝 (𝑦 𝑖 ; 𝑓 𝑖 )=log (1−𝑒− 𝑓 𝑖 𝑦 𝑖 )

Page 20: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

Poisson regression

• When is a positive integer (e.g. spike count)

• Distribution for is Poisson with mean • “Link function” must be positive. Often exponential function, but doesn’t have to be (and it’s not always a good idea).

Page 21: Lasso, Support Vector Machines, Generalized linear models Kenneth D. Harris 20/5/15.

What to read; what software to use

http://web.stanford.edu/~hastie/glmnet_matlab/