53
Online Algorithms Lecturer: Yishay Mansour Elad Walach Alex Roitenberg

Online Algorithms

  • Upload
    benson

  • View
    26

  • Download
    0

Embed Size (px)

DESCRIPTION

Online Algorithms. Lecturer: Yishay Mansour Elad Walach Alex Roitenberg. Introduction. Up until now, our algorithms start with input and work with it suppose input arrives a little at a time, need instant response. Oranges example. - PowerPoint PPT Presentation

Citation preview

Page 1: Online Algorithms

Online AlgorithmsLecturer: Yishay Mansour

Elad WalachAlex Roitenberg

Page 2: Online Algorithms

Introduction Up until now, our algorithms start with

input and work with it suppose input arrives a little at a time,

need instant response

Page 3: Online Algorithms

Oranges example Suppose we are to build a robot that removes

bad oranges from a kibutz packaging line After classification the kibutz worker looks at

the orange and tells our robot if his classification was correct

And repeat indefinitely Our model:

Input: unlabeled orange Output: classification (good or bad) The algorithm then gets the correct classification

Page 4: Online Algorithms

Introduction At every step t, the algorithm predicts the

classification based on some hypothesis The algorithm receives the correct

classification A mistake is an incorrect prediction: The goal is to build an algorithm with a

bound number of mistakes Number of mistakes Independent of the

input size

Page 5: Online Algorithms

Linear Separators

Page 6: Online Algorithms

Linear saperator The goal: find and defining a hyper plane All positive examples will be on the one

side of the hyper plane and all the negative on the other

I.E. for positive only We will now look at several algorithms to

find the separator

Page 7: Online Algorithms

Perceptron The Idea: correct? Do nothing Wrong? Move separator towards mistake We’ll scale all x’s so that , since this

doesn’t affect which side of the plane they are on

Page 8: Online Algorithms

The perceptron algorithm1. initialize 2. Given , predict positive IFF >03. On a mistake:

1. Mistake on positive 2. Mistake on negative

Page 9: Online Algorithms

The perceptron algorithm Suppose a positive sample If we misclassified , then after the

update we’ll get was positive, but since we made a

mistake was negative, so a correction was made in the right direction

Page 10: Online Algorithms

Mistake Bound Theorem Let

M= is the number of mistakes Then where the margin of

the minimal distance of the samples in S from (after normalizing both and the samples)

In tu i t ion:

Page 11: Online Algorithms

Mistake Bound Proof WLOG, the algorithm makes a mistake

on every step (otherwise nothing happens)

Claim 1: Proof:

Page 12: Online Algorithms

Proof Cont. Claim 2:

since the algorithm made a mistake

since the algorithm made a mistake

Page 13: Online Algorithms

Proof Cont. From Claim 1: From Claim 2: Also:

Since Combining:

MwwM *

1

MwM 1

tt www *

1* w

MwwwM MM 1*

1

21

M

Page 14: Online Algorithms

The world is not perfect What if there is no perfect separator?

Page 15: Online Algorithms

The world is not perfect Claim 1(reminder): previously we made γ progress on

each mistake now we might be making negative

progress

So: With claim 2:

TDMwwM *

1

MwwwTDM MM 1*

1

TDM 21

2

Page 16: Online Algorithms

The world is not perfect The total hinge loss of : Alt. definition:

Hinge loss illustration:

*)(),1,0max( wxxlyy

Page 17: Online Algorithms

Perceptron for maximizing margins the idea: update

whenever the correct classification margin is less than

No. of steps polynomial in

Generalization: Update margin: No. of steps polynomial

in

Page 18: Online Algorithms

Perceptron Algorithm (maximizing margin) Assuming

Init: Predict:

On mistake (prediction or margin), update:

Page 19: Online Algorithms

Mistake Bound Theorem Let :

M=No. of mistakes + No. of margin mistakes

Then where the margin of

similar to the perceptron proof. Claim 1 remains the same:We only have to bound

In tu i t ion:

**

1 wwww tt

1tw

Page 20: Online Algorithms

Mistake bound proof WLoG, the algorithm makes a mistake

on every step Claim2: Proof: And since

Page 21: Online Algorithms

Proof Cont. Since the algorithm made a mistake on t

And thus:

Page 22: Online Algorithms

Proof Cont. So: If , From Claim 1 as before: Solving we get:

Page 23: Online Algorithms

The mistake bound model

Page 24: Online Algorithms

Con Algorithm set of concepts consistent on At step t

Randomly choose concept c Predict

Page 25: Online Algorithms

CON Algorithm Theorem: For any concept class C, Con

makes the most mistakes Proof: at first . After each mistake decreases by at least

1 ,since at any t Therefore number of mistakes is bound

by

Page 26: Online Algorithms

The bounds of CON This bound is too high! There are different functions on

We can do better!

Page 27: Online Algorithms

HAL – halving algorithm set of concepts consistent on At step t

Conduct a vote amongst all c Predict with accordance to the majority

Page 28: Online Algorithms

HAL –halving algorithm Theorem: For any concept class C, Con

makes the most mistakes Proof: . After each mistake sine

majority of concepts were wrong. Therefore number of mistakes is bound

by

Page 29: Online Algorithms

Mistake Bound model and PAC Generates strong online algorithms In the past we have seen PAC Restrictions for mistake bound are much

harsher than PAC

If we know that A learns C in mistake bound model , should A learn C in PAC model?

Page 30: Online Algorithms

Mistake Bound model and PAC A – mistake bound algorithm Our goal: to construct Apac a pac algorithm Assume that after A gets xi he construct

hypothesis hi Definition : A mistake bound algorithm A is

conservative iff for every sample xi if then in the ith step the algorithm will make a choice

Mistake madechange hypothesis

Page 31: Online Algorithms

Conservative equivalent of Mistake Bound Algorithm Let A be an algorithm whose mistake is bound by M Ak is A’s hypothesis after it had seen Define A’

Initially . At update:

Guess If Else

If we run A on it would make mistakes makes as many mistakes as A

Page 32: Online Algorithms

Building Apac

Apac algorithm: Run A’ over a sample of size divided to M equal blocks Build hypothesis for each block Run the hypothesis on the next block If there are no mistakes output

Mln1

0kh

1kh

inconsistent

0kh

consistent

inconsistent

1kh

consistent…

Page 33: Online Algorithms

Building Apac If A’ makes at most M mistakes then Apac

guarantees to finish outputs a perfect classifier What happens otherwise? Theorem: Apac learns PAC Proof:

1-M

0

1-M

0kk bad)- is hPr()bad- is h s.t. 10Pr()h bad- outputs Pr(

iiii

PAC MMiA

Page 34: Online Algorithms

Disjunction of Conjuctions

Page 35: Online Algorithms

Disjunction of Conjunctions We have proven that every algorithm in

mistake bound model can be converted to PAC

Lets look at some algorithms in the mistake bound model

Page 36: Online Algorithms

Disjunction Learning Our goal: classify the set of disjunctions

e.g.

Let L be the hypothesis set , …1. h = 2. Given a sample y do:3. If our hypothesis does a mistake () Than:

4. Else do nothing5. Return to step 1 ( update our hypothesis)

Page 37: Online Algorithms

Example If we have only 2 variables

L is , }

Assume the first sample is y=(1,0)

If we update

Page 38: Online Algorithms

Mistake Bound Analysis The number of mistakes is bound

by n+1 n is the number of variables

Proof: Let R be the set of literals in L

Page 39: Online Algorithms

Mistake Bound Analysis For t=0 it is obvious that Assume after t-1 samples

If If than ofcourse S and R don’t intersect. Either way

Thus we can only make mistakes when

Page 40: Online Algorithms

Mistake analysis proof At first mistake we eliminate n literals At any further mistake we eliminate at

least 1 literal L0 has 2n literals

So we can have at most n+1 mistakes

Page 41: Online Algorithms

k-DNF Definition: k-DNF functions are functions

that can be represented by a disjunction of conjunctions in which there are at most k literals E.g. 3-DNF

The number of conjunctions of i terms is We choose i variables ( for each of which

we choose a sign ()

Page 42: Online Algorithms

k-DNF classification We can learn this class by changing the

previous algorithm to deal with terms instead of variables

Reducing the space to gives a disjunction on

2 usable algorithms ELIM for PAC The previous algorithm (In mistake bound

model) which has mistakes

Page 43: Online Algorithms

Winnow Monotone Disjunction: Disjunctions

containing only positive literals.e.g.

Purpose: to learn the class of monotone disjunctions in a mistake-bound model

We look at winnow which is similar to perceptron

One main difference: it uses multiplicative steps rather than additive

Page 44: Online Algorithms

Winnow Same classification scheme as perceptron

Initialize Update scheme:

On positive misclassification (=1, =0) On negative misclassification :

Page 45: Online Algorithms

Mistake bound analysis Similar to perceptron if the margin is

bigger than then we can prove the error rate is )

Page 46: Online Algorithms

Winnow Proof:Definitions Let be the set of relevant variables in

the target concept I.e. We define the weights of the relevant

variables Let be the weight w at time t Let TW(t) be the total weight of all w(t)

of both relevant and irrelevant variables

Page 47: Online Algorithms

Winnow Proof: Positive Mistakes Lets look at the positive mistakes Any mistake on a positive example doubles (at

least) 1 of the relevant weights

If we get therefore always a positive classification

So, can only be doubled at most times Thus, we can bind the number of positive

mistakes:

Page 48: Online Algorithms

Winnow Proof: Positive Mistakes For a positive mistake

() (1)

Page 49: Online Algorithms

Winnow Proof: Negative Mistakes On negative examples none of the

relevant weight change Thus For a negative mistake to occur:

Page 50: Online Algorithms

Winnow Proof:Cont. Combining the equations (1),(2):

(3) At the beginning all weight are 1 so

Page 51: Online Algorithms

What should we know? I Linear Separators

Perceptron algorithm : Margin Perceptron :

The mistake bound model CON algorithm : but C may be very large! HAL the halving algorithm:

Page 52: Online Algorithms

What should you know? II The relation between PAC and the

mistake bound model Basic algorithm for learning disjunction

of conjunctions Learning K-DNF functions Winnow algorithm :

Page 53: Online Algorithms

Questions?