Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

SML_Lecture2

The document discusses statistical learning theory, focusing on the concept of generalization in supervised machine learning. It introduces the Probably Approximately Correct (PAC) Learning framework, which formalizes generalization and outlines conditions for PAC learnability, including sample size requirements. Additionally, it explores examples of learning algorithms, generalization error bounds, and the implications of hypothesis class size on learning performance.

Uploaded by

mohamnaf.b
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SML_Lecture2

The document discusses statistical learning theory, focusing on the concept of generalization in supervised machine learning. It introduces the Probably Approximately Correct (PAC) Learning framework, which formalizes generalization and outlines conditions for PAC learnability, including sample size requirements. Additionally, it explores examples of learning algorithms, generalization error bounds, and the implications of hypothesis class size on learning performance.

Uploaded by

mohamnaf.b
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

CS-E4715 Supervised Machine Learning

Lecture 2: Statistical learning theory


Generalization

ˆ Our aim is to predict as well as possible the outputs of future


examples, not only for training sample
ˆ We would like to minimize the generalization error, or the (true)
risk
R(h) = E(x,y )∼D [ L(h(x), y ) ] ,
where L(y , y 0 ) is a suitable loss function (e.g. zero-one loss)
ˆ Assuming future examples are independently drawn from the same
distribution D that generated the training examples (i.i.d
assumption)
ˆ But we do not know D!
ˆ What can we say about R(h) based on training examples and the
hypothesis class H alone? Two possibilities:
ˆ Empirical evaluation through testing
ˆ Statistical learning theory (Lectures 2 and 3)

1
Additional reading

ˆ Lectures 2-4 are mostly based


on Mohri et al book:
chapters 2-4
ˆ Available online in Aalto
eBookAalto Central (link on
the course home page)
ˆ The book goes much deeper
in the theory (e.g. proofs of
theorems) than what we do
in the course

2
Probably approximately correct
learning
Probably Approximate Correct Learning framework

ˆ Probably Approximate Correct (PAC) Learning framework formalizes


the notion of generalization in machine learning
ˆ Ingredients:
ˆ input space X containing all possible inputs x
ˆ set of possible labels Y (in binary classification Y = {0, 1} or
Y = {−1,+1})
ˆ Concept class C containing concepts C : X 7→ Y (to be learned),
concept C gives a label C (x) for each input x
ˆ unknown probability distribution D
ˆ training sample S = (x1 , C (x1 )), . . . , (xm , C (xm )) drawn
independently from D
ˆ hypothesis class H, in the basic case H = C but this assumption can
be relaxed
ˆ The goal in PAC learning is to learn a hypothesis with a low
generalization error
 
R(h) = Ex∼D L0/1 (h(x), C (x)) = Pr (h(x) 6= C (x))
x∼D
3
PAC learnability

ˆ A class C is PAC-learnable, if there exist an algorithm A that given


a training sample S outputs a hypothesis hS ∈ H that has
generalization error satisfying

Pr (R(hS ) ≤ ) ≥ 1 − δ

ˆ for any distribution D, for arbitrary , δ > 0 and sample size m = |S|
that grows polynomially in 1/,1/δ
ˆ for any concept C ∈ C
ˆ In addition, if A runs in time polynomial in m,1/,and 1/δ the class
is called efficiently PAC learnable
ˆ Learned hypothesis is Probably (1 − δ) Approximately Correct ().

4
Interpretation

Let us interpret the bound

Pr (R(hS ) ≤ ) ≥ 1 − δ

ˆ  sets the level of generalization error that is of interest to us, say we


are content with predicting incorrectly 10% of the new data points:
 = 0.1
ˆ 1 − δ sets a level of confidence, if we are content of the training
algorithm to fail 5% of the time to provide a good hypothesis:
δ = 0.05
ˆ Samples size and running time should not explode when we make 
and δ stricter: requirement of polynomial growth
ˆ The event ”low generalization error”, {R(hS ) ≤ } is considered as a
random variable because we cannot know beforehand which
hypothesis hS ∈ H will be selected by the algorithm
5
Generalization error bound vs. test error

ˆ Generalization error bounds concern


the tail of the error distribution
ˆ We wish a high generalization error
to be a rare event
ˆ Expected generalization error which
might be considerably lower
ˆ Analyzing average behaviour where
most data distributions and
concepts are ”not bad”
ˆ We expect there be a gap between the
expected error and the tail
ˆ The smaller the failure probability δ,
the larger the gap

6
Example: learning axis-aligned
rectangles
Learning setup

ˆ The goal is to learn a


rectangle R (representing the
true concept) that includes
all blue points and excludes
all red points
ˆ The hypotheses also will be
rectangles (here R0 ), which
will in general have both false
positive predictions
(predicting blue when true
label is red) and false
negative predictions
(predicting red when true
label is blue).

7
Example: learning axis-aligned rectangles

ˆ We will use a simple


algorithm: choose the
tightest rectangle that
contains all blue points
ˆ Note that this will be a
consistent hypothesis: no
errors on the training data
ˆ The hypothesis R0 will only
make false negative errors
compared to the true concept
R, no false positive errors (Q:
Why is that?)

8
Example: learning axis-aligned rectangles

Questions:
ˆ Is the class of axis-aligned
rectangles PAC-learnable?
ˆ How much training data will
be needed to learn?
ˆ Need to bound the risk of
outputting a bad hypothesis
R(R0 ) >  with high
probability 1 − δ
ˆ We can assume PrD (R) > 
(otherwise R(R0 ) ≤ 
trivially)

9
Example: learning axis-aligned rectangles

Let r1 , r2 , r3 , r4 be rectangles along the sides of R such that


PrD (ri ) = /4

ˆ Their union satisfies


PrD (r1 ∪ r2 ∪ r3 ∪ r4 ) ≤ 
ˆ Errors can only occur within
R − R0 (false negative
predictions)
ˆ If R0 intersects all of the four
regions r1 , . . . , r4 then we
know that

R(R0 ) ≤ 
Thus, if R(R0 ) >  then R0 must miss at least one of the four regions

10
Example: learning axis-aligned rectangles

ˆ Events A =
{R0 intersects all four rectangles r1 , . . . , r4 },
B = {R(R0 ) ≤ }, satisfy A ⊆ B
ˆ Complement events AC =
{R0 misses at least one rectangle },
BC = {R(R0 ) > } satisfy BC ⊆ AC
ˆ BC is the bad event (high
generalization error), we want it to
have low probability
ˆ In probability space, we have
Pr (BC ) ≤ Pr (AC )
ˆ Our task is to upper bound Pr (AC )

11
Example: learning axis-aligned rectangles

ˆ Each ri has probability mass


/4 by our design
ˆ Probability of one example
missing one rectangle:
1 − /4
ˆ Probability of m examples
missing one rectangle:
(1 − /4)m
(m times repeated trial with
replacement)
ˆ Probability of all examples
missing at least one of the
rectangles:

Pr (AC ) ≤ 4(1 − /4)m


12
Example: learning axis-aligned rectangles

ˆ We can use a general inequality


∀x : (1 − x) ≤ exp(−x) to obtain:

Pr (R(h) > ) ≤ 4(1−/4)m ≤ 4 exp(−m/4)

ˆ We want this probability to be small


(< δ):

4 exp(−m/4) < δ
⇔ m ≥ 4/ log 4/δ

ˆ The last inequality is our first


generalization error bound, a sample
complexity bound to be exact
Note: corresponding to Mohri et al (2018) log denotes the natural
logarithm: log(exp(x)) = x

13
Plotting the behaviour of bound

ˆ Left, the sample complexity, the number of examples needed to


reach a given generalization error level is shown m(, δ) = 4/ log 4/δ
ˆ Right, the generalization bound is plotted as a function of training
sample size (m, δ) = 4/m log 4/δ
ˆ Three different confidence levels (δ) are plotted

14
Plotting the behaviour of the bound

Typical behaviour of ML learning algorithms is revealed:


ˆ increase of sample size decreases generalization error
ˆ extra data gives less and less additional benefit as the sample size
grows (law of diminishing returns)
ˆ requiring high level of confidence (small δ) for obtaining low error
requires more data for the same level of error

15
Generalization error bound vs. expected test error

ˆ The error bounds hold for any


concepts from the class
ˆ including concepts that are harder
to learn than ”average concept”
ˆ They hold for any distribution D
generating the data
ˆ Including adversially generated
distributions (aiming to make
learning harder)
ˆ We bound the probability of being in
the high error tail of the distribution
(not the convergence to the mean or
median generalization error)
For these reasons empirically estimated test errors might be considerably
lower than the bounds suggest

16
Half-time poll: Personalized email spam filtering system
Company is developing a personalized email spam filtering system. The
system is tuned personally for each customer using the customers data on
top of the existing training data. The company has a choice of three
machine learning algorithms, with different performance characteristics.
So far, the company has tested three different algorithms on a small set
of test users.
Which algorithm should the company choose?

1. Algorithm 1, which guarantees error rate of less than 10% for 99%
of the future customer base
2. Algorithm 2, which guarantees error rate of less than 5% for 90% of
the future customer base
3. Algorithm 3, which empirically has error rate of 1% on the current
user base

Answer to the poll in Mycourses by 11:15: Go to Lectures page and scroll


down to ”Lecture 2 poll”:
Answers are anonymous and do not affect grading of the course.
Guarantees for finite hypothesis
sets
Finite hypothesis classes

ˆ Finite concept classes arise when:


ˆ Input variables have finite domains or they are converted to such in
preprocessing (e.g. discretizing real values), and
ˆ The representations of the hypotheses have finite size (e.g. the
number of times a single variable can appear)
ˆ Dealing with subclasses of Boolean formulae, expressions binary
input variables (literals) combined with logical operators (AND, OR,
NOT,...)
ˆ Finite concept classes have been thoroughly analyzed hypothesis
classes in statistical learning theory

17
Example: Boolean conjunctions

ˆ Aldo likes to do sport only when the weather is suitable


ˆ Also has given examples of suitable and not suitable weather
ˆ Let us build a classifier for Aldo to decide whether to do sports today
ˆ As the classifier we use rules in the form of boolean conjunctions
(boolean formulae containing AND, and NOT, but not OR
operators): e.g. if (Sky=Sunny) AND NOT(Wind=Strong) then
(EnjoySport=1)

18
Finite hypothesis class - consistent case

ˆ Sample complexity bound relying on the size of the hypothesis class


(Mohri et al, 2018): Pr (R(hs ) ≤ ) ≥ 1 − δ if

1 1
m≥ (log(|H|) + log( ))
 δ
ˆ An equivalent generalization error bound:
1 1
R(h) ≤ (log(|H|) + log( ))
m δ
ˆ Holds for any finite hypothesis class assuming there is a consistent
hypothesis, one with zero empirical risk
ˆ Extra term compared to the rectangle learning example is the term
1
 (log(|H|))
ˆ The more hypotheses there are in H, the more training examples are
needed

19
Example: Boolean conjunctions

ˆ How many different conjunctions can be built (=|H|)


ˆ Each variable can appear with or without ”NOT” or can be excluded
from the rule = 3 possibilities
ˆ The total number of hypotheses is thus 3d , where d is the number
of variables
ˆ We have six variables in total, giving us |H| = 36 = 729 different
hypotheses

20
Plotting the bound for Aldo’s problem using boolean conjunc-
tions

ˆ On the left, the generalization bound is shown for different values of


δ, using d = 6 variables
ˆ On the right, the bound is shown for increasing number of input
variables d, using δ = 0.05

21
Arbitrary boolean formulae

ˆ What about using arbitrary boolean formulae?


ˆ How many boolean formulae of d variables there are?
ˆ There are 2d possible input vectors, size of the input space is
|X | = 2d
ˆ We can define a boolean formula that outputs 1 for an arbitrary
subset of S ⊂ X and zero outside that subset:
fS (x) = (x = x1 )OR(x = x2 )OR · · · OR(x = x|S| )
ˆ We can pick the subset in 2|X | ways (Why?)
d
ˆ Thus we have |H| = 22 different boolean formula
ˆ Our generalization bound gives
1 d 1
m≥ (2 log 2 + log( ))
 δ
ˆ Thus we need exponential number of examples with respect to the
number of variables; the hypothesis class is considered not
PAC-learnable!
22
Plotting the bound for Arbitrary boolean formulae

ˆ With d = 6 variables we need ca. 500 examples to get bound below


0.07 (left picture)
ˆ Increase of number of variables quickly raises the sample complexity
to 106 and beyond (right picture)

23
Proof outline of the PAC bound
for finite hypothesis classes
Proof outline (Mohri et al., 2018)

ˆ Consider any hypothesis h ∈ H with R(h) > 


ˆ For h to be consistent R̂(h) = 0, all training examples need to miss
the region where h is making an error.
ˆ The probability of this event is

Pr (R̂(h) = 0|R(h) > ) ≤ (1 − )m

ˆ m times repeated trial with success probability 


ˆ This is the probability that one consistent hypothesis has high error

24
Proof outline

ˆ But we do not know which consistent hypothesis h is selected by our


learning algorithm
ˆ Hence our result will need to hold for all consistent hypotheses
ˆ This is an example of uniform convergence bound
ˆ We wish to upper bound the probability that some h ∈ H is
consistent R̂(h) = 0 and has a high generalization error R(h) >  for
a fixed  > 0:

Pr (∃h ∈ H|R̂(h) = 0 ∧ R(h) > )

ˆ Above ∧ is the logical ”and”

25
Proof outline

ˆ We can replace ∃ by enumerating all hypotheses in H using


logical-or (∨)

Pr (∃h ∈ H|R̂(h) = 0 ∧ R(h) > ) =



Pr {R̂(h1 ) = 0 ∧ R(h1 ) > } ∨ {R̂(h2 ) = 0 ∧ R(h2 ) > } ∨ · · ·

ˆ Using the the fact that Pr (A ∪ B) ≤ Pr (A) + Pr (B) and


Pr (A ∩ C ) ≤ Pr (A|C ) for any events A,B and C the above is upper
bounded by
X X
≤ Pr (R̂(h) = 0 ∧ R(h) > ) ≤ Pr (R̂(h) = 0|R(h) > )
h∈H h∈H

≤ |H|(1 − )m

ˆ Last inequality follows from using


Pr (R̂(h) = 0|R(h1 ) > ) ≤ (1 − )m for the |H| summands
26
Proof outline

ˆ We have established

Pr (∃h ∈ H|R̂(h) = 0 ∧ R(h) > ) ≤ |H|(1 − )m ≤ |H| exp(−m)

ˆ Set the right-hand side equal to δ and solve for m to obtain the
bound:

δ = |H| exp (−m)


log δ = log |H| − m
1
m= (log(|H|) + log(1/δ))


27
Finite hypothesis class - inconsistent case

ˆ So far we have assumed that there is a consistent hypothesis h ∈ H,


one that achieves zero empirical risk on training sample
ˆ In practise this is often not the case
ˆ However as long as the empirical risk R̂(h) is small, a low
generalization error can still be achieved
ˆ Generalization error bound (Mohri, et al. 2018): Let H be a finite
hypothesis set. Then for any δ > 0 with probability at least 1 − δ we
have for all h ∈ H:
r
log(|H|) + log(2/δ)
R(h) ≤ R̂(h) +
2m
ˆ We see the dependency from log |H|/m as in the consistent case but
now under square root
ˆ Slower convergence w.r.t number of examples

28
Summary

ˆ Probably approximately correct learning is a theoretical framework


for analysing the generalization performance of machine learning
algorithms
ˆ PAC theory is concerned about upper bounding the probability δ of
”bad” events, those of high generalization error ()
ˆ In finite hypothesis classes, (the logarithm of) number of hypothesis
log |H| in the hypothesis class affects the number of examples
needed to obtain a given level of risk with high probability

29

You might also like