Docsity

Vector Geometry, Slack Variables, Linear Programming | CS 591, Study notes of Programming Languages

Partial preview of the text

Download Vector Geometry, Slack Variables, Linear Programming | CS 591 and more Study notes Programming Languages in PDF only on Docsity!

SVMs Reprised

Administrivia

• I’m out of town Mar 1-

• May have guest lecturer

• May cancel class

• Will let you know more when I do...

Exercise

• Given a hyperplane defined by a weight vector

• What is the equation for points on the surface of

the hyperplane?

• What are the equations for points on the two

margins?

• Give an expression for the distance between a

point and the hyperplane (and/or either margin)

• What is the role of^ w^0?

w = [w 0 , w 1 ,... , wd ]^ T

5 minutes of math...

• A^ dot product^ (inner product) is a^ projection of one

vector onto another

• When the projection of^ x^ onto^ w^ is equal to^ w^0 ,

then x falls exactly onto the w hyperplane

w

Hyperplane

X

w 0 +

∑^ d

i=

wi xi = 0

x · w + w 0 = 0 ⇒ x · w = −w 0

5 minutes of math...

• BTW, are we^ sure^ that hyperplane is perpendicular

to w? Why?

• Consider any two vectors,^ x^1 and^ x^2 , falling exactly

on the hyperplane, then:

⇒ w^ is perpendicular to any vector in the hyperplane

w · x 1 + w 0 = 0 = w · x 2 + w 0 ⇒ w · (x 1 − x 2 ) = 0

(x 1 − x 2 ) is some vector in the hyperplane

5 minutes of math...

• Projections on one side of the line have dot

products >0...

w

Hyperplane x

x · w + w 0 > 0

5 minutes of math...

• What is the distance from any vector^ x^ to the

hyperplane?

w

x

r =?

5 minutes of math...

• What is the distance from any vector hyperplane?^ x^ to the

• Write^ x^ as a point on plane + offset from plane

w

r (^) ‖ww‖

X (^) p

x = x (^) p + r (^) ‖ww‖

Unit vector in direction of w

5 minutes of math...

• Theorem : The distance,^ r , from any point^ x^ to the

hyperplane defined by w and is given by:

• Lemma : The distance from the origin to the

hyperplane is given by:

• Also:^ r >0^ for points on one side of the hyperplane;

r <0 for points on the other

r = (^) ‖ww^0 ‖

w 0

r = w^ ·^ ‖xw^ +‖^ w^0

Back to SVMs & margins

• The margins are parallel to hyperplane, so are

defined by same w , plus constant offsets

w

b^ b

Maximizing the margin

• So now we have a learning criterion function:

• Pick^ w^ to maximize^ b^ s.t. all points still satisfy

• Note: w.l.o.g. can rescale^ w^ arbitrarily (why?)

y (^) i (w · x (^) i + w 0 ) ≥ ‖w‖b

Maximizing the margin

• So now we have a learning criterion function:

• Pick^ w^ to maximize^ b^ s.t. all points still satisfy

• Note: w.l.o.g. can rescale^ w^ arbitrarily (why?)

• So can formulate full problem as:

Minimize: Subject to:

• But how do you do that? And how does this help?

‖w‖ 2

y (^) i (w · x (^) i + w 0 ) ≥ ‖w‖b

y (^) i (w · x (^) i + w 0 ) ≥ 1 ∀i

Nonseparable data

• What if the data isn’t linearly separable?

• Project into higher dim space (we’ll get there)

• Allow some “slop” in the system

• Allow margins to be violated “a little”

w

ξ 1

ξ 2

ξ 3

ξ 4

The new “slackful” QP

• The^ are “slack variables”

• Allow margins to be violated a little

• Still want to minimize margin violations, so add

them to QP instance:

Minimize:

Subject to:

ξi

ξi ≥ 0 ∀i

‖w‖ 2 + C

i

ξi

y (^) i (w · x (^) i + w 0 + ξi ) ≥ 1 ∀i