CS 6316 Machine Learning The Bias-Complexity Tradeoff Yangfeng Ji - - PowerPoint PPT Presentation

cs 6316 machine learning
SMART_READER_LITE
LIVE PREVIEW

CS 6316 Machine Learning The Bias-Complexity Tradeoff Yangfeng Ji - - PowerPoint PPT Presentation

CS 6316 Machine Learning The Bias-Complexity Tradeoff Yangfeng Ji Department of Computer Science University of Virginia Quiz For a real-world machine learning problem, which of the following items are usually available to us? 1 Quiz For a


slide-1
SLIDE 1

CS 6316 Machine Learning

The Bias-Complexity Tradeoff

Yangfeng Ji

Department of Computer Science University of Virginia

slide-2
SLIDE 2

Quiz

For a real-world machine learning problem, which of the following items are usually available to us?

1

slide-3
SLIDE 3

Quiz

For a real-world machine learning problem, which of the following items are usually available to us?

◮ Training set S {(x1, y1), . . . , (xm, ym)} ◮ Domain set X ◮ Label set Y

1

slide-4
SLIDE 4

Quiz

For a real-world machine learning problem, which of the following items are usually available to us?

◮ Training set S {(x1, y1), . . . , (xm, ym)} ◮ Domain set X ◮ Label set Y ◮ Labeling function (the oracle) f ◮ Distribution D over X× Y ◮ The Bayes predictor fD(x)

1

slide-5
SLIDE 5

Quiz

For a real-world machine learning problem, which of the following items are usually available to us?

◮ Training set S {(x1, y1), . . . , (xm, ym)} ◮ Domain set X ◮ Label set Y ◮ Labeling function (the oracle) f ◮ Distribution D over X× Y ◮ The Bayes predictor fD(x) ◮ The size of the hypothesis space H ◮ The empirical risk of a hypothesis h(x) ∈ H, LS(h(x)) ◮ The true risk of a hypothesis h(x) ∈ H, LD(h(x))

1

slide-6
SLIDE 6

Agnostic PAC Learnability

A hypothesis class His agnostic PAC learnable if there exist a function mH : (0, 1)2 → N and a learning algorithm with the following property:

◮ for every distribution D over X× {−1, +1} and ◮ for every ǫ, δ ∈ (0, 1),

when running the learning algorithm on m ≥ mH(ǫ, δ) i.i.d. examples generated by D, the algorithm returns a hypothesis hS1 such that, with probability of at least 1 − δ, LD(hS) ≤ min

h′∈HLD(h′) + ǫ

(1)

1Sometimes, as hS(x) or h(x, S)

2

slide-7
SLIDE 7

The Bayes Optimal Predictor

◮ The Bayes optimal predictor: given a probability

distribution D over X× {−1, +1}, the predictor is defined as fD(x)

+1

if P[y 1|x] ≥ 1

2

−1

  • therwise

(2)

◮ No other predictor can do better: for any predictor h

LD( fD) ≤ LD(h) (3)

3

slide-8
SLIDE 8

The Bayes Optimal Predictor

◮ The Bayes optimal predictor: given a probability

distribution D over X× {−1, +1}, the predictor is defined as fD(x)

+1

if P[y 1|x] ≥ 1

2

−1

  • therwise

(2)

◮ No other predictor can do better: for any predictor h

LD( fD) ≤ LD(h) (3)

◮ Question: is fD ∈ argminh′∈HLD(h′)?

3

slide-9
SLIDE 9

The Gap between hS and fD

For illustration purpose, let us assume the gap between hS and fD can be visualized in the following plot

w1 w2 hS fD ǫ

4

slide-10
SLIDE 10

The Gap between hS and fD

For illustration purpose, let us assume the gap between hS and fD can be visualized in the following plot

w1 w2 hS fD ǫ

◮ hS argminh′∈HLS(h′): learned by minimizing the

empirical risk

◮ fD: the optimal predictor if we know the data

distribution D

4

slide-11
SLIDE 11

Question

Q: For a given hypothesis space H, does fD ∈ argmin

h′

LD(h′) (4) hold?

5

slide-12
SLIDE 12

Question

Q: For a given hypothesis space H, does fD ∈ argmin

h′

LD(h′) (4) hold? A: it depends the selection of the hypothesis space H, usually not. Example: if fD is a nonlinear classifier, while we choose to use logistic regression.

5

slide-13
SLIDE 13

Outline

The previous example implies the error gap between hS and fD can be decomposed into two components

w1 w2 hS fD ǫ

6

slide-14
SLIDE 14

Outline

The previous example implies the error gap between hS and fD can be decomposed into two components

w1 w2 hS fD ǫ

Two different perspectives of the decomposition

◮ The bias-complexity tradeoff: from the perspective of

learning theory

◮ The bias-variance tradeoff: from the perspective of

statistical learning/estimation

6

slide-15
SLIDE 15

The Bias-Complexity Tradeoff

slide-16
SLIDE 16

Basic Learning Procedure

The basic component of formulating a learning process

◮ Input/output space X× Y ◮ Hypothesis space H ◮ Learning via empirical risk minimization

hS ∈ argmin

h′∈H

LS(h′) (5)

◮ Goal: analyzing the true error of hS, LD(hS)

8

slide-17
SLIDE 17

Example

Consider the binary classification problem with the data sampled from the following distribution D 1 2B(x; 5, 1) + 1 2B(x; 1, 2) (6)

9

slide-18
SLIDE 18

Example (Cont.)

Given the distribution, we can compute the true risk/error of the Bayes predictor fD as LD( fD)

  • 1

2B(x < bBayes; 5, 1) + 1 2(1 − B(x < bBayes; 1, 2))

  • 0.11799

(7)

10

slide-19
SLIDE 19

Example (Cont.)

The hypothesis space His defined as hi(x)

+1

x >

i N

−1 x <

i N

(8) where N ∈ N is a predefined integer

11

slide-20
SLIDE 20

Example (Cont.)

The hypothesis space His defined as hi(x)

+1

x >

i N

−1 x <

i N

(8) where N ∈ N is a predefined integer

◮ This is an unrealizable case ◮ The value of N is the size of the hypothesis space

11

slide-21
SLIDE 21

Example (Cont.)

The hypothesis space His defined as hi(x)

+1

x >

i N

−1 x <

i N

(8) where N ∈ N is a predefined integer

◮ This is an unrealizable case ◮ The value of N is the size of the hypothesis space ◮ The best hypothesis in H

h∗ ∈ argmin

h′∈H

LD(h′) (9)

◮ Very likely the best predictor in His not the Bayes

predictor, unless bBayes ∈ { i

N : i ∈ [N]}

11

slide-22
SLIDE 22

Error Decomposition

The error gap between hS and fD can be decomposed as two parts LD(hS) − LD( fD) ǫapp + ǫest (10)

w1 w2 hS fD h∗ ǫapp ǫest 12

slide-23
SLIDE 23

Error Decomposition

The error gap between hS and fD can be decomposed as two parts LD(hS) − LD( fD) ǫapp + ǫest (10)

w1 w2 hS fD h∗ ǫapp ǫest

◮ Approximation error ǫapp caused by selecting a

specific hypothesis space H(model bias)

◮ Estimation error ǫest caused by selecting hS with a

specific training set

12

slide-24
SLIDE 24

Approximation Error ǫapp

To reduce the approximation error ǫapp, we could increase the size of the hypothesis space

w1 w2 hS fD h∗ ǫapp ǫest

The cost is that we also increase the size of training set, in

  • rder to maintain the overall error in the same level (recall

the sample complexity of finite hypothesis spaces).

13

slide-25
SLIDE 25

Approximation Error ǫapp

To reduce the approximation error ǫapp, we could increase the size of the hypothesis space

w1 w2 fD h∗ h∗

The cost is that we also increase the size of training set, in

  • rder to maintain the overall error in the same level (recall

the sample complexity of finite hypothesis spaces).

13

slide-26
SLIDE 26

Estimation Error ǫest

On the other hand, if we use the same training set S, then we may have a larger estimation error

w1 w2 hS fD h∗ h∗ hS 14

slide-27
SLIDE 27

Estimation Error ǫest

On the other hand, if we use the same training set S, then we may have a larger estimation error

w1 w2 hS fD h∗ h∗ hS

The bias-complexity tradeoff: find the right balance to reduce both approximation error and estimation error.

14

slide-28
SLIDE 28

Example: 200 training examples

We randomly sampled 100 examples from each class D 1 2B(x; 5, 1) + 1 2B(x; 1, 2) (11)

15

slide-29
SLIDE 29

Example: 200 training examples

Given 200 training examples, the errors with respect to different hypothesis space is the following (x axis is the size of H) There is a tradeoff with respect to the size of H

16

slide-30
SLIDE 30

Example: 2000 training examples

We randomly sampled 1000 examples from each class D 1 2B(x; 5, 1) + 1 2B(x; 1, 2) (12)

17

slide-31
SLIDE 31

Example: 2000 training examples

With these 2000 training examples, the errors with respect to different hypothesis space is the following Both errors are smaller, but the tradeoff still exists

18

slide-32
SLIDE 32

Example: 2000 training examples

With these 2000 training examples, the errors with respect to different hypothesis space is the following Both errors are smaller, but the tradeoff still exists Exercise: The bias-complexity tradeoff with a Gaussian mixture model.

18

slide-33
SLIDE 33

Summary

Three components in this decomposition

◮ hS ∈ argminh′∈HLS(h′): the ERM predictor given the

training set S

◮ h∗ ∈ argminh′∈HLD(h′): the optimal predictor from H ◮ fD: the Bayes predictor given D

19

slide-34
SLIDE 34

Summary

Three components in this decomposition

◮ hS ∈ argminh′∈HLS(h′): the ERM predictor given the

training set S

◮ h∗ ∈ argminh′∈HLD(h′): the optimal predictor from H ◮ fD: the Bayes predictor given D

Balancing strategy:

◮ we can incrase the complexity of hypothesis space to

reduce the bias, e.g., ◮ enlarge the hypothesis space (as in the running

example)

◮ replacing linear predictors with nonlinear predictors

19

slide-35
SLIDE 35

Summary

Three components in this decomposition

◮ hS ∈ argminh′∈HLS(h′): the ERM predictor given the

training set S

◮ h∗ ∈ argminh′∈HLD(h′): the optimal predictor from H ◮ fD: the Bayes predictor given D

Balancing strategy:

◮ we can incrase the complexity of hypothesis space to

reduce the bias, e.g., ◮ enlarge the hypothesis space (as in the running

example)

◮ replacing linear predictors with nonlinear predictors

◮ in the meantime, we have to increase the training size

to reduce the approximation error.

19

slide-36
SLIDE 36

The Bias-Variance Tradeoff

slide-37
SLIDE 37

A New Perspective

Let us analyze the error ǫ without the assumption of

◮ knowing the best predictor from H,

h∗ ∈ argminh′∈HLD(h′)

◮ changing the size of S

w1 w2 hS fD ǫ

21

slide-38
SLIDE 38

A New Perspective

Let us analyze the error ǫ without the assumption of

◮ knowing the best predictor from H,

h∗ ∈ argminh′∈HLD(h′)

◮ changing the size of S

w1 w2 hS fD ǫ

We still need (1) the ERM predictor hS and (2) the Bayes predictor fD

21

slide-39
SLIDE 39

A New Way of Decomposition

. . . by considering

◮ the randomness in S with m training examples ◮ the average prediction given by E [h(x, S)] where

S ∼ Dm

22

slide-40
SLIDE 40

Data Generation Model

Consider the following data generation model

◮ X ∼ U[0, 1] uniform distribution ◮ Y N(X + sin(2X), σ2) with σ2 0.1

An example of S is

23

slide-41
SLIDE 41

Hypothesis Spaces

Given S and the following hypothesis space H

1

H

1 {w0 + w1x : w0, w1 ∈ R}

(13) the regression result

24

slide-42
SLIDE 42

Hypothesis Spaces (Cont.)

Given S and the following hypothesis space H

3

H

3 {w0 + w1x + w2x2 + w3x3 : w0, w1, w2, w3 ∈ R} (14)

the regression result

25

slide-43
SLIDE 43

Hypothesis Spaces (Cont.)

Given S and the following hypothesis space H

15

H

15 {w0+w1x +· · ·+w15x15 : w0, w1, · · · , w15 ∈ R} (15)

26

slide-44
SLIDE 44

Hypothesis Spaces (Cont.)

Given S and the following hypothesis space H

15

H

15 {w0+w1x +· · ·+w15x15 : w0, w1, · · · , w15 ∈ R} (15)

◮ Intuitively, the degree of the polynomials indicates

the potential/complexity of the hypothesis space

◮ Refer to the VC dimension section for more discussion

26

slide-45
SLIDE 45

Error Decomposition

The difference between the best hypothesis h(x, S) and the Bayes predictor fD(x) is measured as ǫ2 {h(x, S) − fD(x)}2 (16) Introduce E [h(x, S)] into the calculation, we have ǫ2

  • {h(x, S) − E [h(x, S)] + E [h(x, S)] − fD(x)}2

27

slide-46
SLIDE 46

Error Decomposition

The difference between the best hypothesis h(x, S) and the Bayes predictor fD(x) is measured as ǫ2 {h(x, S) − fD(x)}2 (16) Introduce E [h(x, S)] into the calculation, we have ǫ2

  • {h(x, S) − E [h(x, S)] + E [h(x, S)] − fD(x)}2
  • {h(x, S) − E [h(x, S)]}2 + {E [h(x, S)] − fD(x)}2

+2{h(x, S) − E [h(x, S)]} · {E [h(x, S)] − fD(x)}

27

slide-47
SLIDE 47

Review: Mean

Given a random variable X and its probability density function p(x)

◮ Mean: E [X] ∫

xp(x)dx

◮ Approximation to the mean with samples

{x1, . . . , xm} E [X] ≈ 1 m

m

  • i1

xi (17)

◮ Property: E [αX] αE [X] for α is determinstic ◮ Example: the mean of a Gaussian distribution

N(x; µ, σ2) E [X] µ (18)

28

slide-48
SLIDE 48

Review: Variance

Given a random variable X, its probability density function p(x), and its mean E [X]

◮ Variance: Var(X) E

  • (X − E [X])2

◮ Example: the variance of a Gaussian distribution

N(x; µ, σ2) Var(X) σ2 (19)

29

slide-49
SLIDE 49

Review: Variance

Given a random variable X, its probability density function p(x), and its mean E [X]

◮ Variance: Var(X) E

  • (X − E [X])2

◮ Example: the variance of a Gaussian distribution

N(x; µ, σ2) Var(X) σ2 (19) Var(X)

  • E
  • (X − E [X])2
  • E
  • X2 − 2XE [X] + E [X]2
  • E
  • X2

− 2E [X] E [X] + E [X]2

  • E
  • X2

− E [X]2

29

slide-50
SLIDE 50

Error Decomposition (Cont.)

Taking the expectation of ǫ2

E

  • ǫ2
  • E
  • {h(x, S) − E [h(x, S)]}2

+ {E [h(x, S)] − fD(x)}2 +2E [{h(x, S) − E [h(x, S)]}] · {E [h(x, S)] − fD(x)}

30

slide-51
SLIDE 51

Error Decomposition (Cont.)

Taking the expectation of ǫ2

E

  • ǫ2
  • E
  • {h(x, S) − E [h(x, S)]}2

+ {E [h(x, S)] − fD(x)}2 +2E [{h(x, S) − E [h(x, S)]}] · {E [h(x, S)] − fD(x)}

  • E
  • {h(x, S) − E [h(x, S)]}2

+ {E [h(x, S)] − fD(x)}2 +2{E [h(x, S)] − E [h(x, S)]} · {E [h(x, S)] − fD(x)}

30

slide-52
SLIDE 52

Error Decomposition (Cont.)

Taking the expectation of ǫ2

E

  • ǫ2
  • E
  • {h(x, S) − E [h(x, S)]}2

+ {E [h(x, S)] − fD(x)}2 +2E [{h(x, S) − E [h(x, S)]}] · {E [h(x, S)] − fD(x)}

  • E
  • {h(x, S) − E [h(x, S)]}2

+ {E [h(x, S)] − fD(x)}2 +2{E [h(x, S)] − E [h(x, S)]} · {E [h(x, S)] − fD(x)}

  • E
  • {h(x, S) − E [h(x, S)]}2

+ {E [h(x, S)] − fD(x)}2

30

slide-53
SLIDE 53

The Bias-Variance Decomposition

The expected error is decomposed as E

  • ǫ2

E

  • {h(x, S) − E [h(x, S)]}2
  • variance

+ {E [h(x, S)] − fD(x)}2

  • bias2

31

slide-54
SLIDE 54

The Bias-Variance Decomposition

The expected error is decomposed as E

  • ǫ2

E

  • {h(x, S) − E [h(x, S)]}2
  • variance

+ {E [h(x, S)] − fD(x)}2

  • bias2

◮ bias: how far the expected prediction E [h(x, S)]

diverges from the optimal predictor fD(x)

31

slide-55
SLIDE 55

The Bias-Variance Decomposition

The expected error is decomposed as E

  • ǫ2

E

  • {h(x, S) − E [h(x, S)]}2
  • variance

+ {E [h(x, S)] − fD(x)}2

  • bias2

◮ bias: how far the expected prediction E [h(x, S)]

diverges from the optimal predictor fD(x)

◮ variance: how a hypothesis learned from a specific S

diverges from the average prediction E [h(x, S)]

31

slide-56
SLIDE 56

Computing E [h(x, S)]

The key of computing E [h(x, S)] is to eliminate the randomness introduced by S

1: for k 1, · · · , K do 2:

Sample a traing set Sk with size m from the data generation model

3:

Find the best hypothesis via h(x, Sk) ∈ argminh′ L(h′, Sk)

4: end for 5: Output:

E [h(x, S)] ≈ 1 K

K

  • k1

h(x, Sk) The larger K, the better approximation

32

slide-57
SLIDE 57

Example: Bias and Variance

With K 50, m 100, and H

1, we can visualize the bias

and variance of a linear regression example as following High bias and low variance (Underfitting)

33

slide-58
SLIDE 58

Example: Bias and Variance (Cont.)

Same training set with H

3

Both bias and variance are fine

34

slide-59
SLIDE 59

Example: Bias and Variance (Cont.)

Same training set with H

15

Low bias and high variance (Overfitting)

35

slide-60
SLIDE 60

Example: Bias and Variance (Cont.)

Same training set with H

15

Low bias and high variance (Overfitting) Exercise: The bias-variance tradeoff on linear regression with ℓ2 regularization

35

slide-61
SLIDE 61

The Bias-Variance Tradeoff

◮ bias: how far the expected prediction E [h(x, S)]

diverges from the optimal predictor fD(x) ◮ Error of this part is caused by the selection of a

hypothesis space

36

slide-62
SLIDE 62

The Bias-Variance Tradeoff

◮ bias: how far the expected prediction E [h(x, S)]

diverges from the optimal predictor fD(x) ◮ Error of this part is caused by the selection of a

hypothesis space

◮ variance: how a hypothesis learned from a specific S

diverges from the average prediction E [h(x, S)] ◮ Error of this part is caused by using a particular data

set S

36

slide-63
SLIDE 63

The VC Dimension

slide-64
SLIDE 64

Learnability with Infinite Hypotheses

Infinite-size hypothesis space is learnable Examples

◮ Half-space predictor ◮ Logistic regression predictor ◮ Many others

38

slide-65
SLIDE 65

Shattering

For a given set C and a hypothesis space H,

◮ A dichotomy of the set is one of the possible ways of

labeling the points in C using a hypothesis h ∈ H [Mohri et al., 2018, Page 36]

39

slide-66
SLIDE 66

Shattering

For a given set C and a hypothesis space H,

◮ A dichotomy of the set is one of the possible ways of

labeling the points in C using a hypothesis h ∈ H

◮ A set C of m ≥ 1 points is said to be shattered by a

hypothesis space H, if all possible dichotomies of S can be realized by H [Mohri et al., 2018, Page 36]

39

slide-67
SLIDE 67

Shattering: Example

Consider the following set C and the half-space hypothesis space H

half {w0 + w1x1 + w2x2 0 : w0, w1, w2 ∈ R}

(20)

x1 x2

There are 23 8 different ways to label the points and H

half can realized all of them.

40

slide-68
SLIDE 68

VC Dimension

The VC-dimension of a hypothesis space H, denoted VCdim(H), is the maximal size of a set C ⊂ Xthat can be shattered by H. [Shalev-Shwartz and Ben-David, 2014, Page 70]

41

slide-69
SLIDE 69

VC Dimension

The VC-dimension of a hypothesis space H, denoted VCdim(H), is the maximal size of a set C ⊂ Xthat can be shattered by H. A: How to find the VC-dimension of a given hypothesis space? Q: The proof consists of two parts:

◮ There exists a set C of size d that is shattered by H ◮ Every set C of size d + 1 is not shattered by H

[Shalev-Shwartz and Ben-David, 2014, Page 70]

41

slide-70
SLIDE 70

Half Spaces

Consider a special case as following, where VC-dim(H

half) 3

H

half {w0 + w1x1 + w2x2 0 : w0, w1, w2 ∈ R}

(21) (1) Exist a case

x1 x2

42

slide-71
SLIDE 71

Half Spaces

Consider a special case as following, where VC-dim(H

half) 3

H

half {w0 + w1x1 + w2x2 0 : w0, w1, w2 ∈ R}

(21) (1) Exist a case

x1 x2

(2) For any case

x1 x2

42

slide-72
SLIDE 72

Axis-aligned Rectangles

Let Hbe the class of axis-aligned rectangle, formally H {h(a1,a2,b1,b2) : a1 ≤ a2 and b1 ≤ b2} (22) where h(a1,a2,b1,b2)(x1, x2)

+1

x1 ∈ [a1, a2]and x2 ∈ [b1, b2] −1

  • therwise

43

slide-73
SLIDE 73

Axis-aligned Rectangles

Let Hbe the class of axis-aligned rectangle, formally H {h(a1,a2,b1,b2) : a1 ≤ a2 and b1 ≤ b2} (22) where h(a1,a2,b1,b2)(x1, x2)

+1

x1 ∈ [a1, a2]and x2 ∈ [b1, b2] −1

  • therwise

Exist a case

43

slide-74
SLIDE 74

Axis-aligned Rectangles

Let Hbe the class of axis-aligned rectangle, formally H {h(a1,a2,b1,b2) : a1 ≤ a2 and b1 ≤ b2} (22) where h(a1,a2,b1,b2)(x1, x2)

+1

x1 ∈ [a1, a2]and x2 ∈ [b1, b2] −1

  • therwise

For any case

43

slide-75
SLIDE 75

Axis-aligned Rectangles

Let Hbe the class of axis-aligned rectangle, formally H {h(a1,a2,b1,b2) : a1 ≤ a2 and b1 ≤ b2} (22) where h(a1,a2,b1,b2)(x1, x2)

+1

x1 ∈ [a1, a2]and x2 ∈ [b1, b2] −1

  • therwise

For any case VC-dim(H

rect) 4

43

slide-76
SLIDE 76

VC Dimension and the Number of Parameters

◮ For linear predictors, the VC dimensions are equal to

the numbers of parameters H

half {w0 + w1x1 + w2x2 0 : w0, w1, w2 ∈ R} (23)

x1 x2

◮ However, the case is not always true. Considering the

following hypothesis space

44

slide-77
SLIDE 77

Sine Functions

The hypothesis space of sine functions is defined as H

sin {sin(α · x) : α ∈ R}

(24)

−6 −4 −2 2 4 6 −0.5 0.5 1

◮ α π

4

◮ α π

2

◮ α π

45

slide-78
SLIDE 78

Sine Functions

The hypothesis space of sine functions is defined as H

sin {sin(α · x) : α ∈ R}

(24)

−6 −4 −2 2 4 6 −0.5 0.5 1

◮ α π

4

◮ α π

2

◮ α π

45

slide-79
SLIDE 79

Sine Functions

The hypothesis space of sine functions is defined as H

sin {sin(α · x) : α ∈ R}

(24)

−6 −4 −2 2 4 6 −0.5 0.5 1

◮ α π

4

◮ α π

2

◮ α π

45

slide-80
SLIDE 80

Sine Functions

The hypothesis space of sine functions is defined as H

sin {sin(α · x) : α ∈ R}

(24)

−6 −4 −2 2 4 6 −0.5 0.5 1

◮ α π

4

◮ α π

2

◮ α π

VC-dim(H

sin) ∞

45

slide-81
SLIDE 81

Reference

Mohri, M., Rostamizadeh, A., and Talwalkar, A. (2018). Foundations of machine learning. MIT press. Shalev-Shwartz, S. and Ben-David, S. (2014). Understanding machine learning: From theory to algorithms. Cambridge university press.

46