Docsity

Support Vector Machines - Lecture Slides | LING 696, Assignments of Linguistics

Partial preview of the text

Download Support Vector Machines - Lecture Slides | LING 696 and more Assignments Linguistics in PDF only on Docsity!

Homework

  • WSD results on development set:

always assign 01 88.40% most frequent sense 92.61% most frequent possible sense 92.73%

bulba% paste out props.dev | distr feel {’01’: 11} bulba% paste senses.dev props.dev | distr feel {’02’: 3, ’XX’: 1, ’01’: 7}

Homework

[A1 A&W Brands ] [V lost ] [A2 14 ] to [A4 27 ].

Support Vector Machines

  • Empirical Risk Minimization finds a function f ∈ F which minimizes the training error
  • Structural Risk Minimization finds a function f ∈ F which minimizes a bound on the generalization error (which depends on the training error and model capacity)
  • For a separating hyperplane, increasing the margin decreases the capacity
  • This, plus SRM, yields the optimal margin classifier (Vapnik 1982): find the canonical hyperplane which separates the training data and maximizes the margin

Support Vector Machines

  • Finding the optimal separating hyperplane is a quadratic programming problem (optimizing a quadratic function with linear constraints on the variables)
  • Similar problems come up in operations research and finance, and methods for solving quadratic programs are well established
  • In case the training data is not separable (or even if it is), we can use a soft margin algorithm which allows a certain amount of ‘slack’
  • This is a big improvement over the perceptron, but is still limited to linear decision boundaries

Support Vector Machines

  • SVMs are much harder to understand and to implement than other learning methods
  • But, the ‘leading ideas’ aren’t so bad, and there are a number of high quality implementations around for us to use
  • Besides the obvious, work on SVMs has had two significant contributions to machine learning in general:

? validated results of statistical learning theory (especially SRM) ? showed the benefit of using simple learners + kernel functions to learn complex concepts

  • demo, demo, demo

Loss functions

  • What are SVMs really doing?
  • Recall that boosting turned out to be an algorithm to minimize the exponential loss
  • This is similar to maximum entropy methods, which minimize the negative logistic log-likelihood
  • SVMs can also be fit into the same framework. They find the solution to: min β

i

[1 − yi f (xi; β)]+ + λ ||β||^2

  • This is the hinge loss [1 − yi f (xi; β)]+ plus a quadratic penalty or regularization term

Loss functions

  • The hinge loss is an upper bound on the zero-one loss, a natural for classification, and the logistic log-likelihood of MaxEnt models is very similar
  • This gives us another perspective on Gaussian prior smoothing
  • This also gives a unified framework for linking SVMs, MaxEnt, boosting, and many other types of models:

min β

L(y, f ) + λ J(β)

  • New methods can be developed by tinkering with the loss and penalty functions

Implementation

  • While we know how to solve quadratic programs in general, SVMs are particularly challenging
  • Many generic QP codes need the entire n × n Gram matrix
  • Others return extremely small values instead of zeros ( 10 −^17 ≈ 0 )
  • Most training points are irrelevant, so we can use active set methods
  • Memoization can speed up calculation of K(xi, xj)
  • Chunking starts with a small training set, and gradually adds items that get misclassified

Kernel functions

  • Much of the power of SVMs derives from the kernel trick
  • Designing an appropriate kernel can make a huge difference (there’s No Free Lunch!)
  • Linear, polynomial, and RBF kernels are a good place to start
  • If K 1 and K 2 are kernels, and α 1 , α 2 ≥ 0 , then:

K(xi, xj) = α 1 K 1 (xi, xj) + α 2 K 2 (xi, xj) K(xi, xj) = K 1 (xi, xj) K 2 (xi, xj)

are also kernels

String kernels

  • Linear kernels can be computed efficiently for sparse bag-of-words models
  • If f (w, x) is the freqeuency of for w in document x, then computing the dot product:

K(xi, xj) =

w

f (w, xi) f (w, xj)

has cost that depends on the length of the documents, not the size of the vocabulary

  • But, why use a bag of words?

? efficiency ? independence

String kernels

  • A linear kernel is comparable to a mapping like:

c a t r b φ(cat) 1 1 1 0 0 φ(car) 1 1 0 1 0 φ(bat) 0 1 1 0 1 φ(bar) 0 1 0 1 1

  • Similarity between words depends only on the number of letters they have in common, not their order or proximity

String kernels

  • An alternative would represent a word as a set of possibly discontinuous n grams
  • The trigram c-r-d characterizes the words car d and c ust ar d, but the former more than the latter
  • We use a decay factor λ ( 0 < λ < 1 ), so that if a match that spans n characters, it gets a weight of λn
  • Using bigrams, this mapping would give us:

c-a c-t a-t b-a b-t c-r a-r b-r φ(cat) λ^2 λ^3 λ^2 0 0 0 0 φ(car) λ^2 0 0 0 0 λ^3 λ^2 φ(bat) 0 0 λ^2 λ^2 λ^3 0 0 φ(bar) 0 0 0 λ^2 0 0 λ^2 λ^3

String kernels

  • This string subsequence kernel (SSK) can be extended to entire documents
  • For interesting subsequence sizes and document lengths, explicit computation of all of the features would be impractical
  • A very similar problem arises in bioinformatics: comparing DNA sequences
  • We can use dynamic programming to efficiently evaluate the kernel function without constructing the feature vectors
  • The can also be computed using suffix trees, a compact representation of the substrings in a text¡

String kernels

  • Let Σn^ be the set of all strings of length n. To construct the feature mapping φ for a string s, we define the u coordinate for each u ∈ Σn:

φu(s) =

i:u=s[i]

λl(i)

  • The kernel function is given by:

Kn(s, t) =

u∈Σn

φu(s) · φu(t)

u∈Σn

i:u=s[i]

j:u=t[j]

λl(i)+l(j)