Support Vector Machines
Derivation of hard and soft margin SVMs from maximum-margin geometry, the dual formulation via Lagrangian optimization, KKT conditions, the kernel trick, and the representer theorem connecting SVMs to reproducing kernel Hilbert spaces.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- Hard-Margin SVM: Maximum Margin Classifier
- The Lagrangian Dual Problem
- KKT Conditions and Support Vectors
- Soft-Margin SVM
- The Kernel Trick
- Common Kernels
- The Representer Theorem
- Hinge Loss Interpretation
- Common Pitfalls
- Research Perspective
- Summary
- Exercises
Learning Objectives
- Derive the maximum-margin hyperplane for linearly separable data.
- Formulate the dual problem via Lagrange multipliers and interpret it geometrically.
- State and verify the KKT complementary slackness conditions.
- Extend to non-separable data via slack variables (soft-margin).
- Apply the kernel trick to obtain nonlinear decision boundaries without explicit feature maps.
- Connect hinge loss + L2 regularization to the SVM objective.
Notation
- with — training data
- , — weight vector and bias
- — functional margin
- — dual variables (Lagrange multipliers)
- — kernel function
- — slack variables
- — misclassification penalty (inverse regularization)
Core Intuition
Among all hyperplanes that correctly classify the training data, the SVM selects the one with maximum margin — the largest distance to the nearest data point. This maximizes robustness to perturbations and, by VC-theory, yields favorable generalization bounds. The solution depends only on a few "support vectors" — the critical data points lying on the margin boundary.
Support Vector Machine
Hard-Margin SVM: Maximum Margin Classifier
For linearly separable data, we seek a hyperplane such that:
The geometric margin (distance from hyperplane to nearest point) is . Maximizing the margin is equivalent to:
This is a convex quadratic program (QP) with linear constraints.
The Lagrangian Dual Problem
Introduce multipliers :
Setting :
Setting :
Substituting back into yields the dual problem:
The dual depends on data only through inner products — this is the entry point for kernelization.
KKT Conditions and Support Vectors
The KKT complementary slackness conditions state:
This means either (point is not a support vector, lies strictly beyond the margin) or (point lies exactly on the margin — a support vector).
The solution is a sparse linear combination of training points, with nonzero only for support vectors.
Soft-Margin SVM
For non-separable data, introduce slack variables :
The dual becomes:
The box constraint is the only difference from the hard-margin dual.
The Kernel Trick
Replace inner products with where maps to a (possibly infinite-dimensional) feature space:
The decision function becomes:
We never compute explicitly — only kernel evaluations.
Mercer's Theorem. is a valid kernel if and only if it is symmetric and positive semi-definite: for all and .
Common Kernels
- Linear:
- Polynomial:
- RBF (Gaussian):
- Corresponds to infinite-dimensional feature space.
- controls the "locality" of influence.
The Representer Theorem
Theorem. For any regularized empirical risk minimization problem of the form:
the minimizer admits the representation .
This justifies the kernel SVM: even though may be infinite-dimensional, the optimal solution lies in the -dimensional subspace spanned by .
Hinge Loss Interpretation
The soft-margin SVM is equivalent to minimizing:
This is hinge loss + L2 regularization, connecting SVMs to the general framework of regularized loss minimization. The hinge loss is a convex upper bound on the 0-1 classification loss.
Common Pitfalls
Pitfall 1. Forgetting to scale features. SVMs use distances/inner products; features on different scales distort the geometry.
Pitfall 2. Using RBF kernel with incorrect . Too large → each point only influences itself (overfitting). Too small → all points look similar (underfitting).
Pitfall 3. Expecting SVMs to scale to very large datasets. The dual has variables; solving the QP is – in practice. Use SGD on the primal hinge loss for large .
Research Perspective
SVMs were the dominant classification method from the mid-1990s to early 2010s (Vapnik, 1995; Cortes & Vapnik, 1995). Their theoretical appeal lies in the margin-based generalization bounds and the elegant kernel framework. The kernel trick has since been reinterpreted through the Neural Tangent Kernel lens, connecting SVMs to infinite-width neural networks. Modern large-scale kernel methods use random Fourier features (Rahimi & Recht, 2007) to approximate RBF kernels in linear time.
Summary
- Hard-margin SVM finds the maximum-margin separating hyperplane via a convex QP.
- The dual depends only on inner products → enables kernelization.
- Support vectors are the only data points that determine the solution.
- Soft-margin handles non-separable data via slack variables and penalty .
- Kernel trick implicitly maps to high-dimensional spaces without computing the map.
- SVM hinge loss + L2 regularization.
Exercises
Exercise 1. Show that the distance from a point to the hyperplane is .
Exercise 2. Derive the dual problem (equation 6) from the Lagrangian by eliminating and .
Exercise 3. Verify the KKT conditions for a simple 2D example with 3 points.
Exercise 4. Show that the polynomial kernel corresponds to a specific finite-dimensional feature map (write it explicitly for ).
Exercise 5. Prove that the RBF kernel is positive semi-definite by expanding as an infinite series.