CS代考计算机代写 algorithm Boosting Approach to ML Perceptron, Margins, Kernels

Boosting Approach to ML Perceptron, Margins, Kernels
Maria-Florina Balcan 03/18/2015

• •
Recap from last time: Boosting
General method for improving the accuracy of any given learning algorithm.
Works by creating a series of challenge datasets s.t. even modest performance on these can be used to produce an overall high-accuracy predictor.
Adaboost one of the top 10 ML algorithms.
• Works amazingly well in practice.
• Backed up by solid foundations.

Adaboost (Adaptive Boosting)
Input: S={(x1, 𝑦1), …,(xm, 𝑦m)}; xi ∈ 𝑋, 𝑦𝑖 ∈ 𝑌 = {−1,1} weak learning algo A (e.g., Naïve Bayes, decision stumps)
• Fort=1,2,…,T
• Construct Dt on {x1, …, xm} ht
• RunAonDt producinght:𝑋→{−1,1} Output Hfinal 𝑥 = sign 𝑡=1 𝛼𝑡h𝑡 𝑥
D uniform on {x , …, x }
1 1 m [i.e.,D1𝑖=𝑚1]
Given Dt and ht set
+ + + ++
+ +
+
– – –
• •
– – – – –
𝐷𝑡+1 𝑖 = 𝐷𝑡 𝑖 e −𝛼𝑡 𝑍𝑡
𝐷𝑡+1𝑖=𝐷𝑡𝑖 e𝛼𝑡 𝑍𝑡
if 𝑦𝑖 = h𝑡 𝑥𝑖 if𝑦𝑖≠h𝑡𝑥𝑖
𝐷𝑡 𝑖
𝐷𝑡+1 𝑖 = 𝑍𝑡 e 𝑡 𝑖 𝑡 𝑖
Dt+1 puts half of weight on examples xi where ht is incorrect & half on examples where ht is correct
−𝛼 𝑦 h 𝑥
𝛼𝑡=1ln1−𝜖𝑡 >0 2 𝜖𝑡

• •

Nice Features of Adaboost
Very general: a meta-procedure, it can use any weak learning algorithm!!! (e.g., Naïve Bayes, decision stumps)
Very fast (single pass through data each round) & simple to code, no parameters to tune.
Grounded in rich theory.

Analyzing Training Error
Theorem
𝑡
So, if ∀𝑡,𝛾𝑡 ≥ 𝛾 > 0, then 𝑒𝑟𝑟𝑆 𝐻𝑓𝑖𝑛𝑎𝑙 ≤ exp −2𝛾2𝑇
𝜖𝑡 =1/2−𝛾𝑡 (errorofh𝑡 over𝐷𝑡) 𝑒𝑟𝑟𝑆 𝐻𝑓𝑖𝑛𝑎𝑙 ≤exp −2 𝛾𝑡2
The training error drops exponentially in T!!!
Toget𝑒𝑟𝑟𝑆 𝐻𝑓𝑖𝑛𝑎𝑙 ≤𝜖,needonly𝑇=𝑂 1 log 1 rounds
Adaboost is adaptive
• Doesnotneedtoknow𝛾orTapriori • Can exploit 𝛾𝑡 ≫ 𝛾
𝛾2 𝜖

Generalization Guarantees
Theorem 𝑒𝑟𝑟𝑆 𝐻𝑓𝑖𝑛𝑎𝑙 ≤ exp
−2
𝛾𝑡2
𝑡
where 𝜖𝑡 = 1/2 − 𝛾𝑡
How about generalization guarantees?
Original analysis [Freund&Schapire’97]
• H space of weak hypotheses; d=VCdim(H)
𝐻𝑓𝑖𝑛𝑎𝑙 is a weighted vote, so the hypothesis class is: G={all fns of the form sign( 𝑇𝑡=1 𝛼𝑡h𝑡(𝑥)) }
Theorem [Freund&Schapire’97]
∀ 𝑔 ∈ 𝐺, 𝑒𝑟𝑟 𝑔 ≤ 𝑒𝑟𝑟𝑆 𝑔 + 𝑂 𝑇𝑑 T= # of rounds 𝑚
Key reason: VCd𝑖𝑚 𝐺 = 𝑂 𝑑𝑇 plus typical VC bounds.

Generalization Guarantees
Theorem [Freund&Schapire’97]
∀𝑔∈𝐺,𝑒𝑟𝑟𝑔 ≤𝑒𝑟𝑟𝑆 𝑔 +𝑂
𝑇𝑑 𝑚
where d=VCdim(H)
error
train error
generalization error
complexity
T= # of rounds

Generalization Guarantees
• Experiments showed that the test error of the generated classifier usually does not increase as its size becomes very large.
• Experiments showed that continuing to add new weak learners after correct classification of the training set had been achieved could further improve test set performance!!!

Generalization Guarantees
• Experiments showed that the test error of the generated classifier usually does not increase as its size becomes very large.
• Experiments showed that continuing to add new weak learners after correct classification of the training set had been achieved could further improve test set performance!!!
• These results seem to contradict FS’97 bound and Occam’s razor (in order achieve good test error the classifier should be as simple as possible)!
𝑇𝑑 𝑚
∀𝑔∈𝐺,𝑒𝑟𝑟𝑔 ≤𝑒𝑟𝑟𝑆 𝑔 +𝑂

How can we explain the experiments?
R. Schapire, Y. Freund, P. Bartlett, W. S. Lee. present in “Boosting the margin: A new explanation for the effectiveness of voting methods” a nice theoretical explanation.
Key Idea:
Training error does not tell the whole story.
We need also to consider the classification confidence!!

Boosting didn’t seem to overfit…(!)
…because it turned out to be increasing the margin of the classifier
train error
test error of base classifier (weak learner)
test error
Error Curve, Margin Distr. Graph – Plots from [SFBL98]

Classification Margin
• H space of weak hypotheses. The convex hull of H: 𝑐 𝑜 𝐻 = 𝑓 = 𝑇𝑡 = 1 𝛼 𝑡 h 𝑡 , 𝛼 𝑡 ≥ 0 , 𝑇𝑡 = 1 𝛼 𝑡 = 1 , h 𝑡 ∈ 𝐻
• Let𝑓∈𝑐𝑜 𝐻 ,𝑓= 𝑇𝑡=1𝛼𝑡h𝑡,𝛼𝑡 ≥0, 𝑇𝑡=1𝛼𝑡 =1.
The majority vote rule 𝐻𝑓 given by 𝑓 (given by 𝐻𝑓 = 𝑠𝑖𝑔𝑛(𝑓 𝑥 ))
predicts wrongly on example (𝑥, 𝑦) iff 𝑦𝑓 𝑥 ≤ 0.
Definition: margin of 𝐻𝑓 (or of 𝑓) on example (𝑥, 𝑦) to be 𝑦𝑓(𝑥). 𝑇𝑇
𝑦𝑓𝑥=𝑦 𝛼𝑡h𝑡𝑥 = 𝑡=1
𝑦𝛼𝑡h𝑡𝑥 =
𝛼𝑡− 𝛼𝑡 𝑡:𝑦≠h𝑡 𝑥
𝑡=1
𝑡:𝑦=h𝑡 𝑥
The margin is positive iff 𝑦 = 𝐻𝑓 𝑥 .
See 𝑦𝑓 𝑥
= |𝑓 𝑥 | as the strength or the confidence of the vote.
-1 Low confidence
High confidence, incorrect
1
High confidence, correct

Boosting and Margins
Theorem:VCdim(𝐻) = 𝑑, then with prob. ≥ 1 − 𝛿, ∀𝑓 ∈ 𝑐𝑜(𝐻), ∀𝜃 > 0,
P r 𝑦 𝑓 𝑥 ≤ 0 ≤ P r 𝑦 𝑓 𝑥 ≤ 𝜃 + 𝑂 1 d l n 2 𝑚𝑑 + l n 1 𝐷 𝑆 𝑚𝜃2𝛿
Note: bound does not depend on T (the # of rounds of boosting), depends only on the complex. of the weak hyp space and the margin!

Boosting and Margins Theorem:VCdim(𝐻) = 𝑑, then with prob. ≥ 1 − 𝛿, ∀𝑓 ∈ 𝑐𝑜(𝐻), ∀𝜃 > 0,
P r 𝑦 𝑓 𝑥 ≤ 0 ≤ P r 𝑦 𝑓 𝑥 ≤ 𝜃 + 𝑂 1 d l n 2 𝑚𝑑 + l n 1 𝐷 𝑆 𝑚𝜃2𝛿
• If all training examples have large margins, then we can approximate the final classifier by a much smaller classifier.
• Can use this to prove that better marginsmaller test error, regardless of the number of weak classifiers.
• Can also prove that boosting tends to increase the margin of training examples by concentrating on those of smallest margin.
• Although final classifier is getting larger, margins are likely to be increasing, so the final classifier is actually getting closer to a simpler classifier, driving down test error.

Boosting and Margins
Theorem:VCdim(𝐻) = 𝑑, then with prob. ≥ 1 − 𝛿, ∀𝑓 ∈ 𝑐𝑜(𝐻), ∀𝜃 > 0,
P r 𝑦 𝑓 𝑥 ≤ 0 ≤ P r 𝑦 𝑓 𝑥 ≤ 𝜃 + 𝑂 1 d l n 2 𝑚𝑑 + l n 1 𝐷 𝑆 𝑚𝜃2𝛿
Note: bound does not depend on T (the # of rounds of boosting), depends only on the complex. of the weak hyp space and the margin!

Boosting, Adaboost Summary
• Shift in mindset: goal is now just to find classifiers a bit better than random guessing.
• Backed up by solid foundations.
• Adaboost work and its variations well in practice with many kinds of data (one of the top 10 ML algos).
• More about classic applications in Recitation.
• Relevant for big data age: quickly focuses on “core difficulties”, so well-suited to distributed settings, where data must be communicated efficiently [Balcan-Blum-Fine-Mansour COLT’12].

Interestingly, the usefulness of margin recognized in Machine Learning since late 50’s.
Perceptron [Rosenblatt’57] analyzed via geometric (aka 𝐿2, 𝐿2) margin.
Original guarantee in the online learning scenario.

The Perceptron Algorithm
• Online Learning Model • Margin Analysis
• Kernels

• •
Example arrive sequentially. We need to make a prediction.
Afterwards observe the outcome.
For i=1, 2, …, : Phase i:
Mistake bound model
The Online Learning Model
Online Algorithm
Example 𝑥𝑖 Prediction h(𝑥𝑖)
Observe c∗(𝑥𝑖)
• Analysis wise, make no distributional assumptions.
• Goal: Minimize the number of mistakes.

The Online Learning Model. Motivation
– Email classification (distribution of both spam and regular mail changes over time, but the target function stays fixed – last year’s spam still looks like spam).
– Recommendation systems. Recommending movies, etc.
– Predicting whether a user will be interested in a new news article or not.
– Add placement in a new market.

Linear Separators
• Instance space X = Rd
• Hypothesis class of linear decision
surfaces in Rd. •hx=w⋅x+w0,ifh𝑥≥0,thenX X
label x as +, otherwise label it as – Claim: WLOG w0 = 0.
Proof: Can simulate a non-zero threshold with a dummy input feature 𝑥0 that is always set up to 1.
• 𝑥= 𝑥1,…,𝑥𝑑 →𝑥= 𝑥1,…,𝑥𝑑,1
• w⋅x+w0≥0iff 𝑤1,…,𝑤𝑑,w0 ⋅𝑥≥0
wherew= 𝑤1,…,𝑤𝑑
X X
X O
O O
XX XXw
X
O
O
O O O

Linear Separators: Perceptron Algorithm
• Set t=1, start with the all zero vector 𝑤1.
• Given example 𝑥, predict positive iff 𝑤𝑡 ⋅ 𝑥 ≥ 0
• On a mistake, update as follows:
• Mistake on positive, then update 𝑤𝑡+1 ← 𝑤𝑡 + 𝑥
• Mistake on negative, then update 𝑤𝑡+1 ← 𝑤𝑡 − 𝑥
Note: 𝑤𝑡 is weighted sum of incorrectly classified examples 𝑤𝑡 =𝑎𝑖1𝑥𝑖1 +⋯+𝑎𝑖𝑘𝑥𝑖𝑘
𝑤𝑡 ⋅ 𝑥 = 𝑎𝑖1 𝑥𝑖1 ⋅ 𝑥 + ⋯ + 𝑎𝑖𝑘 𝑥𝑖𝑘 ⋅ 𝑥
Important when we talk about kernels.

Perceptron Algorithm: Example
Example: −1,2 − X – 1,0 + 
1,1 + X
+
+ +
𝑤1 = (0,0)
𝑤2=𝑤1− −1,2 =(1,−2)
𝑤3=𝑤2+ 1,1 =(2,−1) 𝑤4=𝑤3− −1,−2 =(3,1)
−1,0 − −1,−2 − 1,−1 +
- X
-
Algorithm:
 Set t=1, start with all-zeroes weight vector 𝑤1.  Given example 𝑥, predict positive iff 𝑤𝑡 ⋅ 𝑥 ≥ 0.  On a mistake, update as follows:
• Mistake on positive, update 𝑤𝑡+1 ← 𝑤𝑡 + 𝑥 • Mistake on negative, update 𝑤𝑡+1 ← 𝑤𝑡 − 𝑥

Geometric Margin
Definition: The margin of example 𝑥 w.r.t. a linear sep. 𝑤 is the distance from 𝑥 to the plane 𝑤 ⋅ 𝑥 = 0 (or the negative if on wrong side)
Margin of positive example 𝑥1 𝑥1
Margin of negative example 𝑥2
𝑥2
w

Geometric Margin
Definition: The margin of example 𝑥 w.r.t. a linear sep. 𝑤 is the distance from 𝑥 to the plane 𝑤 ⋅ 𝑥 = 0 (or the negative if on wrong side)
Definition: The margin 𝛾𝑤 of a set of examples 𝑆 wrt a linear separator 𝑤 is the smallest margin over points 𝑥 ∈ 𝑆.
+ +
++
+
+
– 𝛾 𝛾𝑤 𝑤
+
w
+
— –


– –

Geometric Margin
Definition: The margin of example 𝑥 w.r.t. a linear sep. 𝑤 is the distance from 𝑥 to the plane 𝑤 ⋅ 𝑥 = 0 (or the negative if on wrong side)
Definition: The margin 𝛾𝑤 of a set of examples 𝑆 wrt a linear separator 𝑤 is the smallest margin over points 𝑥 ∈ 𝑆.
Definition: The margin 𝛾 of a set of examples 𝑆 is the maximum 𝛾𝑤 over all linear separators 𝑤.
w
+
-𝛾𝛾 —
+
++
+


– –

Perceptron: Mistake Bound
(Normalized margin: multiplying all points by 100, or dividing all points by 100, doesn’t change the number of mistakes; algo is invariant to scaling.)
Theorem: If data has margin 𝛾 and all points inside a ball of radius 𝑅, then Perceptron makes ≤ 𝑅/𝛾 2 mistakes.
+
–   + + w*
+ —++
+
-R
— –

Perceptron Algorithm: Analysis
Update rule:
• Mistake on positive: 𝑤𝑡+1 ← 𝑤𝑡 + 𝑥
• Mistake on negative: 𝑤𝑡+1 ← 𝑤𝑡 − 𝑥
Proof:
Idea: analyze 𝑤𝑡 ⋅ 𝑤∗ and ‖𝑤𝑡‖, where 𝑤∗ is the max-margin sep, ‖𝑤∗‖ = 1.
Theorem: If data has margin 𝛾 and all points inside a ball of radius 𝑅, then Perceptron makes ≤ 𝑅/𝛾 2 mistakes.
Claim 1: 𝑤𝑡+1 ⋅ 𝑤∗ ≥ 𝑤𝑡 ⋅ 𝑤∗ + 𝛾. Claim 2: 𝑤𝑡+1 2 ≤ 𝑤𝑡 2 + 𝑅2.
After 𝑀 mistakes:
𝑤𝑀+1 ⋅ 𝑤∗ ≥ 𝛾𝑀 (by Claim 1)
𝑤𝑀+1 ≤ 𝑅 𝑀 (by Claim 2)
𝑤𝑀+1 ⋅ 𝑤∗ ≤ ‖𝑤𝑀+1‖ (since 𝑤∗ is unit length)
So, 𝛾𝑀 ≤ 𝑅 𝑀, so 𝑀 ≤
(because 𝑙 𝑥 𝑥 ⋅ 𝑤∗ ≥ 𝛾)
(by Pythagorean Theorem)
𝑤𝑡+1
𝑥
𝑤𝑡
𝑅 2. 𝛾

Perceptron Extensions
• Can use it to find a consistent separator (by cycling through the data).
• One can convert the mistake bound guarantee into a distributional guarantee too (for the case where the 𝑥𝑖s come from a fixed distribution).
• Can be adapted to the case where there is no perfect
separator as long as the so called hinge loss (i.e., the total distance needed to move the points to classify them correctly large
margin) is small.
• Can be kernelized to handle non-linear decision boundaries!

Perceptron Discussion
• Simple online algorithm for learning linear separators with a nice guarantee that depends only on the geometric
(aka 𝐿2, 𝐿2) margin.
• It can be kernelized to handle non-linear decision boundaries — see next class!
• Simple, but very useful in applications like Branch prediction; it also has interesting extensions to structured prediction.