Introduction to Statistical Learning Jean-Philippe Vert - - PowerPoint PPT Presentation

introduction to statistical learning
SMART_READER_LITE
LIVE PREVIEW

Introduction to Statistical Learning Jean-Philippe Vert - - PowerPoint PPT Presentation

Introduction to Statistical Learning Jean-Philippe Vert Jean-Philippe.Vert@ensmp.fr Mines ParisTech and Institut Curie Master Course, 2011. Jean-Philippe Vert (Mines ParisTech) 1 / 46 Outline Introduction 1 Linear methods for regression 2


slide-1
SLIDE 1

Introduction to Statistical Learning

Jean-Philippe Vert Jean-Philippe.Vert@ensmp.fr

Mines ParisTech and Institut Curie

Master Course, 2011.

Jean-Philippe Vert (Mines ParisTech) 1 / 46

slide-2
SLIDE 2

Outline

1

Introduction

2

Linear methods for regression

3

Linear methods for classification

4

Nonlinear methods with positive definite kernels

Jean-Philippe Vert (Mines ParisTech) 2 / 46

slide-3
SLIDE 3

Outline

1

Introduction

2

Linear methods for regression

3

Linear methods for classification

4

Nonlinear methods with positive definite kernels

Jean-Philippe Vert (Mines ParisTech) 2 / 46

slide-4
SLIDE 4

Outline

1

Introduction

2

Linear methods for regression

3

Linear methods for classification

4

Nonlinear methods with positive definite kernels

Jean-Philippe Vert (Mines ParisTech) 2 / 46

slide-5
SLIDE 5

Outline

1

Introduction

2

Linear methods for regression

3

Linear methods for classification

4

Nonlinear methods with positive definite kernels

Jean-Philippe Vert (Mines ParisTech) 2 / 46

slide-6
SLIDE 6

Outline

1

Introduction

2

Linear methods for regression

3

Linear methods for classification

4

Nonlinear methods with positive definite kernels

Jean-Philippe Vert (Mines ParisTech) 3 / 46

slide-7
SLIDE 7

Motivations

Predict the risk of second heart from demographic, diet and clinical measurements Predict the future price of a stock from company performance measures Recognize a ZIP code from an image Identify the risk factors for prostate cancer and many more applications in many areas of science, finance and industry where a lot of data are collected.

Jean-Philippe Vert (Mines ParisTech) 4 / 46

slide-8
SLIDE 8

Learning from data

Supervised learning

An outcome measurement (target or response variable) which can be quantitative (regression) or categorial (classification) which we want to predicted based on a set of features or descriptors or predictors) We have a training set with features and outcome We build a prediction model, or learner to predict outcome from features for new unseen objects

Unsupervised learning

No outcome Describe how data are organized or clustered

Examples - Fig 1.1-1.3

Jean-Philippe Vert (Mines ParisTech) 5 / 46

slide-9
SLIDE 9

Learning from data

Supervised learning

An outcome measurement (target or response variable) which can be quantitative (regression) or categorial (classification) which we want to predicted based on a set of features or descriptors or predictors) We have a training set with features and outcome We build a prediction model, or learner to predict outcome from features for new unseen objects

Unsupervised learning

No outcome Describe how data are organized or clustered

Examples - Fig 1.1-1.3

Jean-Philippe Vert (Mines ParisTech) 5 / 46

slide-10
SLIDE 10

Learning from data

Supervised learning

An outcome measurement (target or response variable) which can be quantitative (regression) or categorial (classification) which we want to predicted based on a set of features or descriptors or predictors) We have a training set with features and outcome We build a prediction model, or learner to predict outcome from features for new unseen objects

Unsupervised learning

No outcome Describe how data are organized or clustered

Examples - Fig 1.1-1.3

Jean-Philippe Vert (Mines ParisTech) 5 / 46

slide-11
SLIDE 11

Machine learning / data mining vs statistics

They share many concepts and tools, but in ML: Prediction is more important than modelling (understanding, causality) There is no settled philosophy or theoretical framework We are ready to use ad hoc methods if they seem to work on real data We often have many features, and sometimes large training sets. We focus on efficient algorithms, with little or no human intervention. We often use complex nonlinear models dfs

Jean-Philippe Vert (Mines ParisTech) 6 / 46

slide-12
SLIDE 12

Organization

Focus on supervised learning (regression and classification) Reference: "The Elements of Statistical Learning" by Hastie, Tibshirani and Friedman (HTF) Available online at http: //www-stat.stanford.edu/~tibs/ElemStatLearn/ Practical sessions using R

Jean-Philippe Vert (Mines ParisTech) 7 / 46

slide-13
SLIDE 13

Notations

Y ∈ Y the response (usually Y = {−1, 1} or R) X ∈ X the input (usually X = Rp) x1, . . . , xN observed inputs, stored in the N × p matrix X y1, . . . , yN observed inputs, stored in the vector Y ∈ YN

Jean-Philippe Vert (Mines ParisTech) 8 / 46

slide-14
SLIDE 14

Simple method 1: Linear least squares

Parametric model for β ∈ Rp+1: fβ(X) = β0 +

p

  • i=1

βiXi = X ⊤β Estimate ˆ β from training data to minimize RSS(β) =

N

  • i=1

(yi − fβ(xi))2 See Fig 2.1 Good if model is correct...

Jean-Philippe Vert (Mines ParisTech) 9 / 46

slide-15
SLIDE 15

Simple method 2: Nearest neighbor methods (k-NN)

Prediction based on the k nearest neighbors: ˆ Y(x) = 1 k

  • xi∈Nk(x)

yi Depends on k Less assumptions that linear regression, but more risk of

  • verfitting

Fig 2.2-2.4

Jean-Philippe Vert (Mines ParisTech) 10 / 46

slide-16
SLIDE 16

Statistical decision theory

Joint distribution Pr(X, Y) Loss function L(Y, f(X)), e.g. squared error loss L(Y, f(X)) = (Y − f(X))2 Expected prediction error (EPE): EPE(f) = E(X,Y)∼Pr(X,Y)L(Y, f(X)) Minimizer is f(X) = E(Y | X) (regression function) Bayes classifier for 0/1 loss in classification (Fig 2.5)

Jean-Philippe Vert (Mines ParisTech) 11 / 46

slide-17
SLIDE 17

Least squares and k-NN

Least squares assumes f(x) is linear, and pools over values of X to estimate the best parameters. Stable but biased k-NN assumes f(x) is well approximated by a locally constant function, and pools over local sample data to approximate conditional expectation. Less stable but less biased.

Jean-Philippe Vert (Mines ParisTech) 12 / 46

slide-18
SLIDE 18

Local methods in high dimension

If N is large enough, k-NN seems always optimal (universally consistent) But when p is large, curse of dimension:

No method can be "local’ (Fig 2.6) Training samples sparsely populate the input space, which can lead to large bias or variance (eq. 2.25 and Fig 2.7-2.8)

If structure is known (eg, linear regression function), we can reduce both variance and bias (Fig. 2.9)

Jean-Philippe Vert (Mines ParisTech) 13 / 46

slide-19
SLIDE 19

Bias-variance trade-off

Assume Y = f(X) + ǫ, on a fixed design. Y(x) is random because of ǫ, ˆ f(X) is random because of variations in the training set T . Then Eǫ,T

  • Y − ˆ

f(X) 2 = EY 2 + Eˆ f(X)2 − 2EYˆ f(X) = Var(Y) + Var(ˆ f(X)) +

  • EY − Eˆ

f(X) 2 = noise + bias(ˆ f)2 + variance(ˆ f)

Jean-Philippe Vert (Mines ParisTech) 14 / 46

slide-20
SLIDE 20

Structured regression and model selection

Define a family of function classes Fλ, where λ controls the "complexity", eg: Ball of radius λ in a metric function space Bandwidth of the kernel is a kernel estimator Number of basis functions For each λ, define ˆ fλ = argmin

EPE(f) Select ˆ f = ˆ fˆ

λ to minimize the bias-variance tradeoff (Fig. 2.11).

Jean-Philippe Vert (Mines ParisTech) 15 / 46

slide-21
SLIDE 21

Cross-validation

A simple and systematic procedure to estimate the risk (and to

  • ptimize the model’s parameters)

1

Randomly divide the training set (of size N) into K (almost) equal portions, each of size K/N

2

For each portion, fit the model with different parameters on the K − 1 other groups and test its performance on the left-out group

3

Average performance over the K groups, and take the parameter with the smallest average performance. Taking K = 5 or 10 is recommended as a good default choice.

Jean-Philippe Vert (Mines ParisTech) 16 / 46

slide-22
SLIDE 22

Summary

To learn complex functions in high dimension from limited training sets, we need to optimize a bias-variance trade-off. We will do that typically by:

1

Define a family of learners of various complexities (eg, dimension

  • f a linear predictor)

2

Define an estimation procedure for each learner (eg, least-squares or empirical risk minimization)

3

Define a procedure to tune the complexity of the learner (eg, cross-validation)

Jean-Philippe Vert (Mines ParisTech) 17 / 46

slide-23
SLIDE 23

Outline

1

Introduction

2

Linear methods for regression

3

Linear methods for classification

4

Nonlinear methods with positive definite kernels

Jean-Philippe Vert (Mines ParisTech) 18 / 46

slide-24
SLIDE 24

Linear least squares

Parametric model for β ∈ Rp+1: fβ(X) = β0 +

p

  • i=1

βiXi = X ⊤β Estimate ˆ β from training data to minimize RSS(β) =

N

  • i=1

(yi − fβ(xi))2 Solution if X⊤X is non-singular: ˆ β =

  • X⊤X

−1 X⊤Y

Jean-Philippe Vert (Mines ParisTech) 19 / 46

slide-25
SLIDE 25

Fitted values

Fitted values on the training set: ˆ Y = Xˆ β = X

  • X⊤X

−1 X⊤Y = HY with H = X

  • X⊤X

−1 X⊤ Geometrically: H projects Y on the span of X (Fig. 3.2) If X is singular, ˆ β is not uniquely defined, but ˆ Y is

Jean-Philippe Vert (Mines ParisTech) 20 / 46

slide-26
SLIDE 26

Inference on coefficients

Assume Y = Xβ + ǫ, with ǫ ∼ N(0, σ2I) Then ˆ β ∼ N

  • β, σ2

X⊤X

  • − 1
  • Estimating variance: ˆ

σ = Y − ˆ Y 2/(N − p − 1) Statistics on coefficients: ˆ βj − βj ˆ σ√vj ∼ tN−p−1 allows to test the hypothesis H0 : βj = 0, and gives confidence intervals ˆ βj ± tα/2,N−p−1ˆ σvj

Jean-Philippe Vert (Mines ParisTech) 21 / 46

slide-27
SLIDE 27

Inference on the model

Compare a large model with p1 features to a smaller model with p0 features: F = (RSS0 − RSS1) / (p1 − p0) RSS1/ (N − p1 − 1) follows the Fisher law Fp1−p0,N−p1−1 under the hypothesis that the small model is correct.

Jean-Philippe Vert (Mines ParisTech) 22 / 46

slide-28
SLIDE 28

Gauss-Markov theorem

Assume Y = Xβ + ǫ, where Eǫ = 0 and Eǫǫ⊤ = σ2I. Then the least squares estimator ˆ β is BLUE (best linear unbiased estimator), i.e., for any other estimator ˜ β = CY with E ˜ β = β, Var(ˆ β) ≤ Var ˜ β Nevertheless, we may have smaller total risk by increasing bias to decrease variance, in particular in the high-dimensional setting.

Jean-Philippe Vert (Mines ParisTech) 23 / 46

slide-29
SLIDE 29

Gauss-Markov theorem

Assume Y = Xβ + ǫ, where Eǫ = 0 and Eǫǫ⊤ = σ2I. Then the least squares estimator ˆ β is BLUE (best linear unbiased estimator), i.e., for any other estimator ˜ β = CY with E ˜ β = β, Var(ˆ β) ≤ Var ˜ β Nevertheless, we may have smaller total risk by increasing bias to decrease variance, in particular in the high-dimensional setting.

Jean-Philippe Vert (Mines ParisTech) 23 / 46

slide-30
SLIDE 30

Decreasing the complexity of linear models

1

Feature subset selection

2

Penalized criterion

3

Feature construction

Jean-Philippe Vert (Mines ParisTech) 24 / 46

slide-31
SLIDE 31

Feature subset selection

Best subset selection

Usually NP-hard, "leaps and bound" procedure works for up to p = 40 Best k selected by cross-validation of various criteria (Fig 3.5)

Greedy selection: forward, backward, hybrid

Jean-Philippe Vert (Mines ParisTech) 25 / 46

slide-32
SLIDE 32

Ridge regression

Minimize RSS(β) + λ

p

  • i=1

β2

i

Solution: ˆ βλ =

  • X⊤X + λI

−1 X⊤Y If X⊤X = I (orthogonal design), then ˆ βλ = ˆ β/(1 + λ), otherwise nonlinear solution path Fig 3.8 Equivalent to shrinking on the small principal components (Fig 3.9)

Jean-Philippe Vert (Mines ParisTech) 26 / 46

slide-33
SLIDE 33

Lasso

Minimize RSS(β) + λ

p

  • i=1

| βi | No explicit solution, but convex quadratic program and efficient algorithm for the solution path (LARS, Fig. 3.10) Performs feature selection because the ℓ1 ball has singularities (Fig 3.11

Jean-Philippe Vert (Mines ParisTech) 27 / 46

slide-34
SLIDE 34

Discussion

In orthogonal design, best subset selection, ridge regression and Lasso correspond to 3 different ways to shrink the ˆ β coefficients (Fig 3.10) They minimize RSS(β) over respectively the ℓ0, ℓ2 and ℓ1 balls Generalization: penalize by β q, but:

convex problem only for q ≥ 1 feature selection only for q ≤ 1

Generalization: group lasso, fused lasso, elastic net...

Jean-Philippe Vert (Mines ParisTech) 28 / 46

slide-35
SLIDE 35

Using derived input space

PCR

OLS on the top M principal components Similar to ridge regression, but truncates instead of shrinking

PLS

Similar to PCR but uses Y to construct the directions: maximize max

α

Corr 2(Y, Xα)Var(Xα)

Jean-Philippe Vert (Mines ParisTech) 29 / 46

slide-36
SLIDE 36

Outline

1

Introduction

2

Linear methods for regression

3

Linear methods for classification

4

Nonlinear methods with positive definite kernels

Jean-Philippe Vert (Mines ParisTech) 30 / 46

slide-37
SLIDE 37

Supervised classification

Y = {−1, 1} (can be generalized to K classes) Goal: estimate P(Y = k | X = x), or (easier) ˆ Y(x) = arg maxk P(Y = k | X = x) Approach: estimate a function f : X → R and predict according to ˆ Y(x) =

  • 1

if f(x) ≥ 0 , −1 if f(x) < 0 . 3 strategies

1

Model P(X, Y) (LDA)

2

Model P(Y | X) (logistic regression)

3

Separate positives from negative examples (SVM)

Jean-Philippe Vert (Mines ParisTech) 31 / 46

slide-38
SLIDE 38

Linear discriminant analysis (LDA)

Model P(Y = k) = πk and P(X | Y = k) ∼ N (µk, Σ) Estimation: ˆ πk = Nk N ˆ µk = 1 Nk

  • i:yi=k

xi ˆ Σ = 1 N − 1

  • k∈{−1,1}
  • i:yi=k

(xi − µk) (xi − µk)⊤ Prediction: ln P(Y = 1 | X = x) P(Y = −1 | X = x) = x⊤ ˆ Σ−1 (µ1 − µ−1) − 1 2 ˆ µ⊤

2 ˆ

Σ−1ˆ µ2 + 1 2 ˆ µ⊤

1 ˆ

Σ−1ˆ µ1 + ln N1 N2

Jean-Philippe Vert (Mines ParisTech) 32 / 46

slide-39
SLIDE 39

Remarks on LDA

If a ˆ Σ is estimated on each class, we obtain a quadratic function : quadratic discriminant analysis (QDA) LDA performs linear discrimination f(X) = β⊤X + b. β can also be found by OLS, taking Yi = Ni/N Good baseline method, even if the data are not Gaussian

Jean-Philippe Vert (Mines ParisTech) 33 / 46

slide-40
SLIDE 40

Quadratic discriminant analysis (QDA)

Model P(Y = k) = πk and P(X | Y = k) ∼ N (µk, Σ) Estimation: same as LDA except ˆ Σk = 1 Nk

  • i:yi=k

(xi − µk) (xi − µk)⊤ Prediction: ln P(Y = k | X = x) P(Y = l | X = x) = δk(x) − δl(x) with δk(x) = −1 2 ln |Σk| − 1 2 (x − µk)⊤ Σ−1

k

(x − µk) + ln πk

Jean-Philippe Vert (Mines ParisTech) 34 / 46

slide-41
SLIDE 41

Logistic regression

Model:    P(Y = 1 | X = x) =

eβ⊤x 1+eβ⊤x

P(Y = −1 | X = x) =

1 1+eβ⊤x

Equivalently P(Y = y | X = x) = 1 1 + e−yβ⊤x Equivalently, ln P(Y = 1 | X = x) P(Y = −1 | X = x) = β⊤x

Jean-Philippe Vert (Mines ParisTech) 35 / 46

slide-42
SLIDE 42

Logistic regression: parameter estimation

Likelihood: ℓ(β) = −

N

  • i=1

ln

  • 1 + e−yiβ⊤xi
  • ∂ℓ

∂β (β) =

N

  • i=1

yixi 1 + eyiβ⊤xi =

N

  • i=1

yip(−yi | xi)xi ∂2ℓ ∂β∂β⊤ (β) = −

N

  • i=1

xix⊤

i eβ⊤xi

  • 1 + eβ⊤xi2 =

N

  • i=1

p(1 | xi) (1 − p(1 | xi)) xix⊤

i

Optimization by Newton-Raphson is iteratively reweighted least squares (IRLS) Problem if data linearly separable = ⇒ regularization

Jean-Philippe Vert (Mines ParisTech) 36 / 46

slide-43
SLIDE 43

Regularized logistic regression

Problem if data linearly separable : infinite likelihood possible Classical ℓ2 regularization min

β N

  • i=1

ln

  • 1 + e−yiβ⊤xi
  • + λ

p

  • i=1

β2

i

ℓ1 regularization (feature selection) min

β N

  • i=1

ln

  • 1 + e−yiβ⊤xi
  • + λ

p

  • i=1

| βi |

Jean-Philippe Vert (Mines ParisTech) 37 / 46

slide-44
SLIDE 44

LDA vs Logistic regression

Both methods are linear Estimation is different: model P(X, Y) (likelihood) or P(Y | X) (conditional likelihood) LDA works better if data are Gaussian, but more sensitive to

  • utliers

Jean-Philippe Vert (Mines ParisTech) 38 / 46

slide-45
SLIDE 45

Hard-margin SVM

If data are linearly separable, separate them with largest margin Equivalently, minβ β 2 such that yiβ⊤xi ≥ 1 Dual problem: max

α≥0 N

  • i=1

αi − 1 1

N

  • i=1

N

  • j=1

αiαjyiyjx⊤

i xj

and ˆ βi =

N

  • i=1

yiαixi

Jean-Philippe Vert (Mines ParisTech) 39 / 46

slide-46
SLIDE 46

Soft-margin SVM

If data are not linearly separable, add slack variable: minβ β 2/2 + C N

i=1 ζi such that yiβ⊤xi ≥ 1 − ζi

Dual problem: same as hard-margin with the additional constraint 0 ≤ α ≤ C Equivalently, min

β N

  • i=1

max(0, 1 − yiβ⊤xi) + λ β 2

Jean-Philippe Vert (Mines ParisTech) 40 / 46

slide-47
SLIDE 47

Large-margin classifiers

The margin is yf(x) LDA, logistic and SVM all try to ensure large margin: min

β N

  • i=1

φ(yif(xi)) + λΩ(β) where φ(u) =      (1 − u)2 for LDA ln (1 + e−u) for logistic regression max(0, 1 − u) for SVM

Jean-Philippe Vert (Mines ParisTech) 41 / 46

slide-48
SLIDE 48

Outline

1

Introduction

2

Linear methods for regression

3

Linear methods for classification

4

Nonlinear methods with positive definite kernels

Jean-Philippe Vert (Mines ParisTech) 42 / 46

slide-49
SLIDE 49

Feature expansion

We have seen many linear methods for regression and classification, of the form min

β∈Rp N

  • i=1

L

  • yi, β⊤xi
  • + λ β 2

2

To be nonlinear in x, we can apply them after some transformation x → Φ(x) ∈ Rq, where q may be larger than p Example: nonlinear functions of x, polynomials, ... Notation: we define the kernel corresponding to Φ by K(x, x′) = Φ(x)⊤Φ(x′)

Jean-Philippe Vert (Mines ParisTech) 43 / 46

slide-50
SLIDE 50

Representer theorem

For any solution of ˆ β ∈ arg min

β∈Rp N

  • i=1

L

  • yi, β⊤xi
  • + λ β 2

2

there exists ˆ α ∈ Rn such that ˆ β =

N

  • i=1

ˆ αiΦ(xi) . Consequences: ˆ f(x) =

N

  • i=1

ˆ αiK(xi, x)

Jean-Philippe Vert (Mines ParisTech) 44 / 46

slide-51
SLIDE 51

Solving in α

  • f(xi)

i=1,...,N = Kα and β 2 2 = α⊤Kα, so we can plug α in the

  • ptimization problem instead of β, and only K is needed

Example: kernel ridge regression: ˆ α = (K + λI)−1 Y Example: kernel SVM max

0≤α≤C N

  • i=1

αiyi − 1 N

N

  • i=1

N

  • j=1

αiαjK(xi, xj)

Jean-Philippe Vert (Mines ParisTech) 45 / 46

slide-52
SLIDE 52

Positive definite kernel

Theorem (Aronszajn)

There exists Φ : Rp → Rq for some q (possibly infinite if and only if K is positive definite, i.e., K(x, x′) = K(x′, x) for any x, x′, and

n

  • i=1

n

  • j=1

aiaiK(xi, xj) ≥ 0 for any n, a and x. Examples: Linear: K(x, x′) = x⊤x′ Polynomial: K(x, x′) = (x⊤x′)d Gaussian: K(x, x′) = exp − x − x′ 2/2σ2

Jean-Philippe Vert (Mines ParisTech) 46 / 46