Module IV·Article II·~5 min read
SVM and Kernel Methods
Applications in Machine Learning
Reading tools · save, download, print, audio
Turn this article into a podcast
Pick voices, format, length — AI generates the audio
Idea: Maximize the Margin
Classification problem: given N points , where and are class labels. The goal is to find a hyperplane separating the two classes. There are infinitely many such hyperplanes—any separating one will do. SVM (Support Vector Machine) chooses the "best"—the one maximally distant from both classes. Maximum margin means maximum robustness to new data. The elegance of SVM lies in the fact that finding the optimal hyperplane is a convex quadratic programming problem.
Primal SVM Problem
Hyperplane: . Class of a point : .
Distance from point to the hyperplane: .
Margin = (distance between the two parallel hyperplanes ).
SVM Problem (hard margin): maximize the margin under correct classification:
Equivalently:
This is a convex quadratic programming problem! Unique solution (strictly convex objective).
Dual Problem and the Kernel Trick
Lagrangian:
KKT conditions:
- :
- :
Substituting into the Lagrangian, we obtain the dual problem:
Key observation: the input data enter only via inner products !
Kernel trick: replace with —a kernel function. Then, the SVM implicitly operates in a high-dimensional (possibly infinite-dimensional) feature space, without computing it explicitly.
Support Vectors
From the KKT conditions (complementary slackness): .
Therefore, only for points "on the margin"—. These are the support vectors—the points "closest" to the separating hyperplane. There are usually few of them: in a problem with 1000 points—dozens. Only they determine the solution!
Classification of a new point : —depends only on kernels with support vectors.
Soft Margin SVM
When classes are not separable, add "slack variables" :
The parameter controls the trade-off: large → strict margin (few violations), small → wide margin (many violations allowed). In the dual problem: .
Popular Kernels
Linear: . SVM becomes a linear classifier.
Polynomial: . Operates implicitly in the space of degree polynomial features.
RBF (radial): . Corresponds to an infinite-dimensional space (!) of Gaussian functions. —the "width" parameter. As : memorization; as : linear classifier.
Full Example Analysis
Data (2D, 4 points):
- Class +1: ,
- Class −1: ,
Symmetry: .
By symmetry of the problem: , , and for each pair are opposite → .
Dual Problem: . After computation: , . Margin .
Generalization Guarantees
Theorem: with probability (over random training sample), the SVM error is bounded:
Here is the data norm, is the margin. Feature space dimensionality doesn't appear! The margin, not the model complexity, determines generalization. This is the theoretical basis: large margin = good generalization.
Support Vector Method: Mathematical Core
SVM solves a classification problem by finding a hyperplane with maximum margin between two classes. This is naturally formulated as a QP. The dual form is especially important: it depends only on inner products between training samples, which paves the way for the kernel trick.
Popular Kernels and Their Properties
- Linear: —for linearly separable data
- Polynomial: —for polynomial boundary of degree
- RBF (Gaussian): —infinite-dimensional kernel, universal approximator
- Sigmoid: —related to neural networks
- String kernels, graph kernels—for non-geometric data
Key requirement: Gram matrix must be positive semi-definite (Mercer's theorem). This guarantees that the kernel corresponds to an inner product in some Hilbert space.
Implementation and Scaling
For large data, standard QP does not scale. Specialized algorithms are used:
- SMO (Sequential Minimal Optimization, Platt, 1998): iteratively optimizes pairs of Lagrange multipliers
- Pegasos (Shalev-Shwartz): stochastic gradient descent for linear SVMs
- LIBLINEAR, LIBSVM—standard libraries
Applications
For many years, SVMs were state-of-the-art in text, image, and bioinformatics classification tasks. Before the deep learning era, it was SVM with RBF kernel that won competitions for handwritten digit recognition (MNIST), protein classification, and spam filtering. Today, SVMs remain relevant for small datasets, where deep networks overfit, and in industrial applications requiring model interpretability.
§ Act · what next