Maximum-margin linear classifiers — hyperplanes, functional and geometric margins, the hard-margin optimisation problem and its support vectors, soft margins with slack variables and the parameter C, the hinge-loss view, the dual problem, the kernel trick with polynomial and RBF kernels, hyperparameter effects, and multi-class strategies.
For linearly separable data there are infinitely many separating hyperplanes w⊤x+b=0. The SVM picks the one with the largest margin — the widest "street" between the classes — which generalises best and depends only on the hardest points.
The street between the dashed lines is as wide as possible; only the circled points touch it.
Geometry
Signed distance of x from the hyperplane: ∥w∥w⊤x+b.
Scale w,b so the closest points satisfy yi(w⊤xi+b)=1. Then the margin width is ∥w∥2.
Hard-margin SVM
w,bmin21∥w∥2subject toyi(w⊤xi+b)≥1∀i.
A convex quadratic program with a unique solution. The points with equality are the support vectors.
The hinge loss is zero for points beyond the margin — which is why only support vectors matter — and grows linearly for violations (compare the log loss of logistic regression, which is never exactly zero).
w=∑iαiyixi; only support vectors have αi>0 — the solution is sparse.
The data appear only through inner productsxi⊤xj — the door to kernels.
Prediction: f(x)=sign(∑iαiyixi⊤x+b).
The kernel trick
Map inputs to a feature space ϕ(x) where the classes are separable, and replace every inner product by a kernelK(x,z)=ϕ(x)⊤ϕ(z), computed without forming ϕ.
A function is a valid kernel iff every Gram matrix [K(xi,xj)] is symmetric positive semi-definite (Mercer's condition). Sums, products and positive scalings of kernels are kernels.
Practical notes
Scale features — the margin is defined by distances.
Tune C (and γ for RBF) by cross-validation on a log grid.
Training costs roughly O(n2)–O(n3) for kernel SVMs — fine for thousands of points, slow for millions (use linear SVMs or approximations there).
Multi-class: one-vs-rest (K classifiers) or one-vs-one ((2K) classifiers, majority vote).
SVR (support vector regression) uses an ε-insensitive loss.
Quick revision
Practice questions
GATE-style questions: 5 one-mark and 5 two-mark. Wrong MCQs cost ⅓ of their marks in the real exam; MSQ and NAT have no negative marking. Attempt each before opening the solution.
Q1NAT1 mark
A hard-margin linear SVM has weight vector w=(3,4). The width of its margin, 2/∥w∥, is ______.
Q2NAT2 marks
The distance from the point (1,1) to the hyperplane 3x1+4x2−2=0 is ______.
Q3MCQ1 mark
In a trained SVM, the support vectors are
Q4MSQ2 marks
Which statements about SVMs are correct?
One or more options are correct.
Q5NAT2 marks
For the polynomial kernel K(x,z)=(x⊤z+1)2 with x=(1,2) and z=(3,1), the kernel value is ______.
Q6NAT2 marks
For the RBF kernel K(x,z)=exp(−γ∥x−z∥2) with γ=0.5, x=(0,0) and z=(1,1), the kernel value is ______ (round to two decimals).
Q7NAT1 mark
For a training example with label y=+1 and SVM score f(x)=0.3, the hinge loss max(0,1−yf(x)) is ______.
Q8MCQ2 marks
A hard-margin SVM is trained on just two points: (1,1) with label +1 and (−1,−1) with label −1. The learned classifier is
Q9MCQ1 mark
For an RBF-kernel SVM, a very large γ tends to
Q10NAT1 mark
A one-vs-one multi-class SVM for K=5 classes trains how many binary classifiers? ______