Imagine two groups of points on a page and a ruler you must lay down to separate them. Many positions work — but which is best? A Support Vector Machine answers: the line that leaves the widest empty street between the groups. That single instinct, made precise and extended with the kernel trick, gives one of the most elegant and powerful classifiers ever invented. This chapter sets up the idea, the vocabulary, and why it matters.
The widest-street idea
A Support Vector Machine (SVM) is a supervised model that separates two classes with the maximum-margin decision boundary — the hyperplane that is as far as possible from the nearest points of either class. The nearest points, which “hold up” the boundary, are the support vectors.
Why the widest street? A boundary crammed against the data is fragile — a tiny wiggle in a point flips a prediction. A boundary with a wide buffer is robust: new points have to move a lot before they cross. Maximizing the margin is a built-in safety factor, and (Chapter [ch:theory]) it is exactly what controls how well the model generalizes to unseen data. The SVM does not just separate; it separates with maximum confidence.
The decision rule
An SVM classifies with a linear score and its sign: \[\hat y = \sgn\!\big(\vw^\top\vx + b\big),\] where \(\vw\) is the weight vector (perpendicular to the boundary) and \(b\) is the offset. The boundary is the set \(\vw^\top\vx+b=0\); the margins are the parallel surfaces \(\vw^\top\vx+b=\pm 1\). Training chooses \(\vw,b\) to make the street between those margins as wide as possible while keeping points on the correct side.
Three ideas that make SVMs special
Maximum margin (Chapters [ch:maxmargin], [ch:softmargin]): choose the most robust boundary; allow a few violations with a budget \(C\).
Support vectors (Chapter [ch:duality]): the solution depends only on the handful of boundary points — a sparsity that falls out of the optimization (KKT conditions).
The kernel trick (Chapter [ch:kerneltrick]): because everything depends on inner products \(\vxi^\top\vx_j\), replacing them with a kernel \(k(\vxi,\vx_j)\) draws nonlinear boundaries in a high- (even infinite-) dimensional space without ever computing coordinates there.
A short history
The linear maximal-margin idea goes back to Vapnik and Chervonenkis in the 1960s; the modern SVM — soft margins plus the kernel trick — was introduced by Cortes and Vapnik (1995), building on Boser, Guyon, and Vapnik (1992). Through the late 1990s and 2000s SVMs were the dominant “off-the-shelf” classifier, winning at text categorization, handwriting and digit recognition, and bioinformatics. Deep learning overtook them on large perceptual datasets after 2012, but SVMs remain a first-class tool for small/medium structured data — and their theory underpins modern results connecting kernels to neural networks.
SVMs gave machine learning several durable gifts. The hinge loss they minimize reappears as a standard classification loss in deep networks. The large-margin principle is the ancestor of margin-based and contrastive losses used to train embeddings and face-recognition models. The kernel viewpoint matured into a whole field (Gaussian processes, kernel ridge regression) and, strikingly, modern theory shows an infinitely wide neural network behaves like a kernel machine — a Support Vector Machine with the Neural Tangent Kernel (Chapter [ch:svmmlai]). Learning SVMs is learning the grammar of much of modern ML.
from sklearn.svm import SVC
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
X, y = X[y < 2, :2], y[y < 2] # two classes, two features
clf = SVC(kernel="linear", C=1.0).fit(X, y)
print("accuracy:", clf.score(X, y))
print("number of support vectors per class:", clf.n_support_)
print("w =", clf.coef_.round(2), " b =", round(clf.intercept_[0], 2))Chapter summary
An SVM separates classes with the maximum-margin hyperplane — the widest empty street between them.
The decision rule is \(\hat y=\sgn(\vw^\top\vx+b)\); margins are the surfaces \(\vw^\top\vx+b=\pm 1\).
Only the boundary points — the support vectors — determine the solution.
Three pillars: maximum margin, support-vector sparsity, and the kernel trick for nonlinearity.
Introduced by Cortes & Vapnik (1995); still excellent on small/medium data and foundational to modern ML theory.