Docsity

Understanding Linear Classification in Machine Learning: Perceptron Algorithm and Margin, Slides of Artificial Intelligence

Partial preview of the text

Download Understanding Linear Classification in Machine Learning: Perceptron Algorithm and Margin and more Slides Artificial Intelligence in PDF only on Docsity!

CSE 151 Machine Learning

Linear Classification

Given labeled data:

(xi, yi)

where y is +1 or -1 , find a hyperplane to separate + from -

feature

vector

label

i=1,..,n

Linear Classification Process

Classification Algorithm Training Data

-^ -

- - - - - w

O

Prediction Rule: Vector w How do you classify a test example x?

Output y = sign(￿w, x￿)

The Perceptron Algorithm

Goal: Given labeled data (xi, yi), i=1,..,n, where y is +1 or -1 , Find a vector w such that the corresponding hyperplane separates + from - What does yt￿wt, xt￿^ <^0 mean? When yt = 1, yt￿wt, xt￿^ <^0 means When yt = -1, yt￿wt, xt￿^ <^0 means

￿wt, xt￿ < 0

￿wt, xt￿ > 0

This means wt predicts the label of xt incorrectly Perceptron Algorithm:

  1. Initially, w 1 = y 1 x 1
  2. For t=2, 3,.... If wt+1 = wt + yt xt Else: then: wt+1 = wt yt￿wt, xt￿ ≤ 0

Measure of Separability: Margin

For a unit vector w, and training set S, margin of w is defined as:

γ = min x∈S |￿w, x￿| ￿x￿ min cosine of angle between w and x, for any x in S

Low Margin

w

O

w

O

High Margin

Measure of Separability: Margin

For a unit vector w, and training set S, margin of w is defined as:

γ = min x∈S |￿w, x￿| ￿x￿ min cosine of angle between w and x, for any x in data

Low Margin

w

O

w

O

High Margin

In Class Problem

Given w = (1, 0) and examples:

What is the margin of w wrt the examples?

When does Perceptron work?

Low Margin

w

O

w

O

High Margin

If the training points are linearly separable with margin

then #mistakes made by perceptron is at most 1 /γ

2

Theorem:

and if ￿xi￿^ = 1 for all xi in the training data,

When does Perceptron work?

Proof: Let w* be a linear separator with margin γ^ s.t. ￿w

∗ ￿ = 1 then #mistakes made by perceptron is at most (^1) /γ 2

Theorem: If the training points are linearly separable with margin γ

and if ￿xi￿^ = 1 for all xi in the training data,

When does Perceptron work?

Fact 1. If there is a mistake at round t, ￿wt+1, w ∗ ￿ ≥ ￿wt, w ∗ ￿ + γ

Proof: Let w* be a linear separator with margin γ^ s.t. ￿w

∗ ￿ = 1 then #mistakes made by perceptron is at most (^1) /γ 2

Theorem: If the training points are linearly separable with margin γ

and if ￿xi￿^ = 1 for all xi in the training data,

When does Perceptron work?

Fact 1. If there is a mistake at round t, ￿wt+1, w ∗ ￿ ≥ ￿wt, w ∗ ￿ + γ ￿wt+1, w ∗ ￿ = ￿wt + ytxt, w ∗ ￿ = ￿wt, w ∗ ￿ + yt￿xt, w ∗ ￿ By definition of margin, yt￿xt, w ∗ ￿ ≥ γ Fact 2. If there is a mistake at round t, ￿wt+1￿ 2 ≤ ￿wt￿ 2

  • 1

Proof: Let w* be a linear separator with margin γ^ s.t. ￿w

∗ ￿ = 1 then #mistakes made by perceptron is at most (^1) /γ 2

Theorem: If the training points are linearly separable with margin γ

and if ￿xi￿^ = 1 for all xi in the training data,

When does Perceptron work?

Fact 1. If there is a mistake at round t, ￿wt+1, w ∗ ￿ ≥ ￿wt, w ∗ ￿ + γ ￿wt+1, w ∗ ￿ = ￿wt + ytxt, w ∗ ￿ = ￿wt, w ∗ ￿ + yt￿xt, w ∗ ￿ By definition of margin, yt￿xt, w ∗ ￿ ≥ γ Fact 2. If there is a mistake at round t, ￿wt+1￿ 2 ≤ ￿wt￿ 2

  • 1 ￿wt+1￿ 2 = ￿wt + ytxt￿ 2 = ￿wt￿ 2
  • y 2 t ￿xt￿ 2
  • 2yt￿wt, xt￿ As there is a mistake at round t, yt￿wt, xt￿^ <^0 Also: ￿xt￿ 2 ≤ 1

Proof: Let w* be a linear separator with margin γ^ s.t. ￿w

∗ ￿ = 1 then #mistakes made by perceptron is at most (^1) /γ 2

Theorem: If the training points are linearly separable with margin γ

and if ￿xi￿^ = 1 for all xi in the training data,

When does Perceptron work?

Fact 1. If there is a mistake at round t, ￿wt+1, w ∗ ￿ ≥ ￿wt, w ∗ ￿ + γ Fact 2. If there is a mistake at round t, ￿wt+1￿ 2 ≤ ￿wt￿ 2

  • 1 After M mistakes, ￿wt, w ∗ ￿ ≥ γM

Proof: Let w* be a linear separator with margin γ^ s.t. ￿w

∗ ￿ = 1 ￿wt￿ ≤ √ M then #mistakes made by perceptron is at most (^1) /γ 2

Theorem: If the training points are linearly separable with margin γ

and if ￿xi￿^ = 1 for all xi in the training data,

When does Perceptron work?

Fact 1. If there is a mistake at round t, ￿wt+1, w ∗ ￿ ≥ ￿wt, w ∗ ￿ + γ Fact 2. If there is a mistake at round t, ￿wt+1￿ 2 ≤ ￿wt￿ 2

  • 1 After M mistakes, ￿wt, w ∗ ￿ ≥ γM As w* has norm at most 1,

Proof: Let w* be a linear separator with margin γ^ s.t. ￿w

∗ ￿ = 1 ￿wt￿ ≤ √ M γM ≤ ￿wt, w ∗ ￿ ≤ ￿wt￿ ≤ √ M M ≤ 1 γ 2 Solving, then #mistakes made by perceptron is at most (^1) /γ 2

Theorem: If the training points are linearly separable with margin γ

and if ￿xi￿^ = 1 for all xi in the training data,