ElemedexA pocket encyclopedia of AI architectures
No. 013

Support vector machine

SVM · máquina de vectores de soporte · support-vector network

Maximum Margin

It cares nothing for averages: out of thousands of examples it only remembers the few that ended up pressed against the border. Between two classes it draws the widest possible street, sometimes in a billion-dimensional space it never actually visits.

Height
2 (kernels + sum)
Weight
stores ≈ 18,000 support vectors of 784 values (NIST)
Parameters
1 α per support vector (NIST: ≈ 1,000–2,800 per class)
Context
no sequence: one input vector
Training data
USPS: 7,300 digits · NIST: 60,000
Year
1995
Generation
2 · Classical machine learning
Creators
Cortes & Vapnik (AT&T Bell Labs)
Kind
Algorithm

Base stats

Total
128

Approximate, ordinal scales meant for comparing species with each other; the hard numbers are in the data sheet.

Weaknesses

  • With nonlinear kernels, training is slow and scales poorly to millions of examples.
  • It is shallow: it needs good features (or a good kernel) chosen by a human.
  • The kernel and the C parameter are tuned by trial and error.
  • It separates two classes at a time and outputs distances to the boundary, not probabilities.

Habitat

It was born at Bell Labs reading digits from US mail and from NIST. From the late 1990s on it was a favorite tool for classifying texts, genes and images described by hand-made features; today it survives where data are few and variables many.

Moves

Abilities

Support vectors
Only the examples closest to the boundary define the solution; all the others could be deleted without changing anything.
Kernel trick
Computes dot products in a very high-dimensional, even infinite-dimensional, space without ever building it.
Theoretical guarantees
Statistical learning theory bounds its expected error by the proportion of support vectors, whatever the dimension.

Anatomy

xᵢ and αᵢ are storedLabeled examples (x, ±1)Maximize the marginSupport vectors xᵢ, αᵢNew input xK(x₁, x)K(x₂, x)K(xₛ, x)Σ αᵢyᵢK(xᵢ,x) + bSign → class +1 / −1TrainingPrediction

Left: training solves a quadratic optimization problem and keeps only the support vectors with their weights αᵢ. Right: to classify, the input is compared with each support vector through the kernel K (a dot product in feature space, computed without building that space) and the sign of the weighted sum decides the class. Cortes and Vapnik describe it as a two-layer network.

Evolution chain

013 Support vector machine

A support vector machine (SVM) is a classifier that draws a linear boundary between two classes, but not just any boundary: the one that leaves the widest possible margin between them. Combined with the kernel trick, that boundary can live in a feature space of huge, even infinite, dimension without anyone having to build it. The name is misleading: it is not a machine but an algorithm (Witten et al., 2017, p. 252); its authors called it a support-vector network (Cortes & Vapnik, 1995).

How it works

Maximum margin. If two classes are linearly separable, infinitely many hyperplanes separate them. The SVM picks the one that stays as far as possible from both: geometrically, the perpendicular bisector of the shortest segment joining the convex hulls of the two classes. The examples lying on the margin are called support vectors, and they are the only ones that matter: all the others could be deleted without moving the decision boundary. Finding them is a constrained quadratic optimization problem (Witten et al., 2017, pp. 253–254).

Kernel. A linear boundary is too poor for almost anything. The idea is to transform the input with a nonlinear function and draw the hyperplane in the new space, where a flat plane can correspond to a curved surface in the original one (Witten et al., 2017, p. 252). The cost explodes: a polynomial of degree 4 or 5 over 200 variables requires a space of about a billion dimensions (Cortes & Vapnik, 1995, p. 275). The trick is that the algorithm only ever uses dot products between examples, and certain kernels compute the dot product of the big space by operating in the small one (Witten et al., 2017, p. 255); Boser et al. (1992) had shown this swap of operations (Cortes & Vapnik, 1995, p. 276). A kernel is, at bottom, a similarity measure, and it can be defined over strings, trees or sets (Witten et al., 2017, p. 273). With a Gaussian kernel, the SVM amounts to a radial basis function network with a center on every example; with a sigmoid kernel, to a multilayer perceptron with one hidden layer (Witten et al., 2017, pp. 256, 270).

Soft margin. Real data overlap. The distinctive contribution of Cortes & Vapnik (1995) was to extend the method to non-separable data, tolerating some training errors in exchange for a wide margin (1995, p. 273); a parameter C, tuned by trial and error, governs the trade-off (Witten et al., 2017, p. 256).

What changed

The Perceptron finds some separating hyperplane, which depends on the order in which it saw the data (Witten et al., 2017, p. 261); the SVM finds the best one in a precise sense. That choice brings stability: since the boundary only moves if the support vectors change, the method resists overfitting even in very high-dimensional spaces (Witten et al., 2017, p. 255). And it brings theory: if the optimal hyperplane separates the data, the expected error is bounded by the ratio of support vectors to training examples, a bound that does not depend on the dimension of the space (Cortes & Vapnik, 1995, pp. 275–276).

On 60,000 handwritten NIST digits, a degree-4 polynomial kernel made 1.1% errors without any knowledge of the geometry of images (Cortes & Vapnik, 1995, pp. 289–290). According to Chollet, kernel methods sent neural networks back into oblivion: they performed very well, had theoretical backing and lent themselves to mathematical analysis (Chollet, 2021, secs. 1.2.2–1.2.3).

How many parameters does it have? What is learned is one coefficient per support vector (in the NIST experiment, between roughly 1,000 and 2,800 for each of the ten classifiers), but the model must store those vectors in full: part of the training set is the model, as in k-nearest neighbors. The implicit polynomial, by contrast, would have more than 10⁸ free parameters (Cortes & Vapnik, 1995, p. 289). The data sheet reflects a point in between.

Limits

With nonlinear kernels, training is slow compared with other methods such as decision trees (Witten et al., 2017, p. 256), and it scales poorly to large datasets. Moreover, the SVM is a shallow method: the kernel is chosen by hand, not learned, so on perceptual problems it needs features designed by experts (Chollet, 2021, sec. 1.2.3). When massive data and GPUs arrived, deep learning displaced it; it remains an excellent choice when data are few and variables many.

Sources