Docsity

Nonlinear Discrimination with Support Vector Machines - Lecture Notes | CS 591, Study notes of Programming Languages

Toggle sidebar
bg1
1 Administrivia
•There’s a bug in HW 2, problem 5. The regularization term should be added to the error
term, not subtracted (of course). The repaired version should be online now.
2 Nonlinear discrimination with Support Vector Machines
•Recall that last time, we finished up by covering the nonseparable case for the SVM.
•We ended up with the QP formulation:
min
Wc
WTc
W+DX
i
ξi
subject to yiWTXi≥1∀i
•This is pretty cool, actually, but it only goes so far. It handles a little data nonseparability,
but it breaks pretty badly if the data is highly nonlinear.
•E.g., if the two classes are concentric or something else nasty.
•Now for the mindbending part...
•We still want to be able to handle nonlinear systems. It turns out that if you’re a little bit
clever, you can get there too.
•Iwill not prove it to you in this class, but it’s possible to rewrite the previous system with
some variable transformations as:
max
αiX
i
αi−1
2X
iX
j
αiαjyiyjXi
TXj
Subject to 0≤αi≤D
X
i
αiyi= 0
(No, it’s not obvious, and I told you I wouldn’t prove it to you. Go look up the Burges
tutorial on SVMs if you really want to understand where that came from... )
•The important thing about that expression is that it’s written in terms of a dot product be-
tween the Xi. That is, if you know the value of the dot product, you don’t actually need to
know what the Xithemselves are!
•Why is this useful? Well, suppose that we take our original Xi, which live in
R
d, and project
them into some higher dimensional space,
R
kvia a nonlinear transform Φ(X)(kÀd).
•It may be that kis so large that it’s painful to manipulate (we have examples of k=∞)
1
pf3
pf4
pf5

Partial preview of the text

Download Nonlinear Discrimination with Support Vector Machines - Lecture Notes | CS 591 and more Study notes Programming Languages in PDF only on Docsity!

1 Administrivia

  • There’s a bug in HW 2, problem 5. The regularization term should be added to the error term, not subtracted (of course). The repaired version should be online now.

2 Nonlinear discrimination with Support Vector Machines

  • Recall that last time, we finished up by covering the nonseparable case for the SVM.
  • We ended up with the QP formulation:

min W

WT^ Ŵ + D

i

ξi

subject to yiWTXi ≥ 1 ∀i

  • This is pretty cool, actually, but it only goes so far. It handles a little data nonseparability, but it breaks pretty badly if the data is highly nonlinear.
  • E.g., if the two classes are concentric or something else nasty.
  • Now for the mindbending part...
  • We still want to be able to handle nonlinear systems. It turns out that if you’re a little bit clever, you can get there too.
  • I will not prove it to you in this class, but it’s possible to rewrite the previous system with some variable transformations as:

max αi

i

αi −

i

j

αiαj yiyj XiTXj

Subject to 0 ≤ αi ≤ D ∑

i

αiyi = 0

(No, it’s not obvious, and I told you I wouldn’t prove it to you. Go look up the Burges tutorial on SVMs if you really want to understand where that came from... )

  • The important thing about that expression is that it’s written in terms of a dot product be- tween the Xi. That is, if you know the value of the dot product, you don’t actually need to know what the Xi themselves are!
  • Why is this useful? Well, suppose that we take our original Xi, which live in Rd, and project them into some higher dimensional space, Rk^ via a nonlinear transform Φ(X) (k À d).
  • It may be that k is so large that it’s painful to manipulate (we have examples of k = ∞)
  • But suppose that we have a convenient way to manipulate the product K(Xi, Xj ) = Φ(Xi)Φ(Xj ). Now we could just plug in K in the place of the dot product, above, and carry through the same solution. It turns out to work just fine.
  • Which begs the question of, if you can’t handle Φ, how can you get K?
  • Well, often K is easy to represent, even if Φ is hard. E.g.,

K(Xi, Xj ) = e−^

(Xi−Xj )T(Xi−Xj ) 2 σ^2

which you should recognize as, essentially, being a Gaussian. That’s a K equivalent to an infinite-dimensional Φ (again, I won’t prove this to you). Another example is:

K(Xi, Xj ) = (XiTXj )p

for some integer p > 1. It turns out that if your original Xi ∈ Rd, then this corresponds to a Φ that lives in a space of dimension

(d+p− 1 p

. If you’re looking at, say, 16 × 16 images (d = 256), and p = 4 (you’re looking at a degree-4 polynomial expansion), then Φ is a 183,181,376-dimensional space. Wow!

  • One little fly in the ointment, of course, is that our classifier still depends on a W, which now exists in the Φ space. I.e., W may be infinite dimensional!
  • Thankfully, it turns out that by the same bit of magic that is necessary to rewrite our QP as above, it’s also possible to rewrite our classifier.
  • Recall that our classifer rule was:

f (X) = sign(W TX)

  • This can be rewritten as:

f (X) = sign

i

yiαiK(Xi, X)

where X is the test point, Xi are the training data points, and αi are the auxiliary vars that we introduced in the new QP formulation, above.

  • So we can conveniently express W itself implicitly as the sum of the kernel dot products of the training data with the test data.
  • Furthermore, it turns out that αi > 0 only for the support vectors. This is, in fact, how you identify the support vectors (even for the separable case). Solving the QP will identify them for you, and this sum only has to take place over the support vectors (i.e., α 6 = 0)
  • So far, I’ve completely represented this in terms of binary classification – labels can be either +1 or − 1.
  • What do you do when you have multiclass data?
  • Or as a recursive partitioning of the data space. Note that each split produces a single, axis orthagonal split relative to its local region (defined with respect to its parents). Within each region (leaf), the system returns a constant value (the class).
  • Ok, that’s nice, but where does this set of rules come from?
  • The tree itself is learned from our data; the hypothesis space is the set of all trees over our attributes (large).
  • It’s, in fact, too large to search exhaustively (no surprise).
  • Instead, we’ll build the tree recursively (also no surprise) and greedily.
  • That is, we’ll pick the “best” split at the root that we can, without considering lower levels of the tree, fix that split, and then recurse.
  • So we’ll need a notion of what makes a “good” split. Thoughts?
  • We’ll need the following definition:
  • Definition A data set S is said to be pure iff every x ∈ S has the same label (i.e., ∀xi, xj ∈ S, yi = yj
  • So a split that improves the purity of the data set (i.e., whose children are more pure than their parent) is a good split.
  • So how do we measure purity? More precisely, how do we measure partial purity? I.e., how do we say that one split yields children that are “more pure” than another split?
  • There are a number of commonly used metrics. Probably the most commonly used is en- tropy: H(S) = −

c∈classes(S)

pc log 2 pc

  • Now we’ll use that to construct a criterion for deciding which attribute to split on at any given point in building a tree.
  • What we want is to evaluate which attribute drives the data toward the most pure state. I.e., the one that improves purity most w.r.t. the original set.
  • Problem: Entropy measures the purity of a single set, S. But after we choose an attribute A to split on, we have divided S into a number of different subsets S 1 , S 2 ,... SA.v. How do we evaluate the total entropy of all of the subsets produced by A?
  • Could just sum individual entropies for each subset, but that leads to distortions – consider when an attribute pulls out only a single datum from the set.
  • Better: entropy of a group of sets is the average of entropies of individual sets. Let Sc be the subset of S defined by attribute A = c (c ∈ A.v). Let H(S|A) be the entropy of the split defined by A, then, H(S|A) = −

c∈A.v

|Sc| |S|

H(Sc)

  • Now what we want to ask is, which attribute improves this the most over the raw entropy of S_?_
  • Well, if raw entropy is H(S), then we define the entropy gain , G(S|A) = H(S) − H(S|A). Now we just pick the attribute that maximizes gain. I.e., for our split, we select A such that:

A = arg max p∈Attr

G(S|p)

  • We’ve treated only categorical splits here, but you can also do splits on continuous values by making tests of the form A > 3 vs. A ≤ 3. Do this by sorting the attribute and picking the best split point within that attribute.