βˆ‘GateAndNet
PlannerSign Up
ADVANCEDFrequently Tested 5 min read 4 views

Support Vector Machines (SVM): Margin Duality, KKT Conditions & Kernel Trick

Geometric margin 2/||w|| derivation, Soft-Margin slack variables & hinge loss, Lagrangian dual formulation, KKT complementary slackness, and Mercer RBF/Polynomial kernels.

1. Geometric Margin & Hard-Margin Primal Optimization

Given linearly separable binary data {(xi,yi)}i=1n\{(x_i, y_i)\}_{i=1}^n with yi∈{βˆ’1,+1}y_i \in \{-1, +1\}, fix the scale of (w,b)(w, b) so the closest points lie on the canonical margin boundaries wTx+b=Β±1w^T x + b = \pm 1. The perpendicular distance between parallel hyperplanes wTx+b=+1w^T x + b = +1 and wTx+b=βˆ’1w^T x + b = -1 is:

Ξ³=∣1βˆ’(βˆ’1)∣βˆ₯wβˆ₯2=2βˆ₯wβˆ₯2\gamma = \frac{|1 - (-1)|}{\|w\|_2} = \frac{2}{\|w\|_2}

Maximizing 2βˆ₯wβˆ₯2\frac{2}{\|w\|_2} yields the strictly convex quadratic program (QP):

min⁑w,bβ€…β€Š12βˆ₯wβˆ₯22subjectΒ toyi(wTxi+b)β‰₯1βˆ€i∈{1,…,n}\min_{w, b} \; \frac{1}{2}\|w\|_2^2 \quad \text{subject to} \quad y_i(w^T x_i + b) \ge 1 \quad \forall i \in \{1, \dots, n\}

2. Soft-Margin SVM, Slack Variables & Hinge Loss

For noisy or non-separable data, introduce non-negative slack variables ΞΎiβ‰₯0\xi_i \ge 0:

min⁑w,b,ΞΎβ€…β€Š12βˆ₯wβˆ₯22+Cβˆ‘i=1nΞΎis.t.Β yi(wTxi+b)β‰₯1βˆ’ΞΎi,β€…β€ŠΞΎiβ‰₯0\min_{w, b, \xi} \; \frac{1}{2}\|w\|_2^2 + C \sum_{i=1}^{n} \xi_i \quad \text{s.t. } y_i(w^T x_i + b) \ge 1 - \xi_i, \; \xi_i \ge 0

Eliminating ΞΎi=max⁑(0,1βˆ’yi(wTxi+b))\xi_i = \max\big(0, 1 - y_i(w^T x_i + b)\big) reveals Hinge Loss + L2L_2 Regularization:

Dual Multiplier Ξ±i\alpha_iSlack ΞΎi\xi_iGeometric Location of Point xix_i
Ξ±i=0\alpha_i = 0ΞΎi=0\xi_i = 0Strictly outside margin (yif(xi)>1y_i f(x_i) > 1) β€” Non-Support Vector
0<Ξ±i<C0 < \alpha_i < CΞΎi=0\xi_i = 0Exact Margin Boundary (yif(xi)=1y_i f(x_i) = 1) β€” used to solve for bβˆ—b^*
Ξ±i=C\alpha_i = C0<ΞΎi≀10 < \xi_i \le 1Inside margin but correctly classified
Ξ±i=C\alpha_i = CΞΎi>1\xi_i > 1Misclassified (yif(xi)<0y_i f(x_i) < 0) β€” Bounded Support Vector
Common Exam Mistake

Moving Non-Support Vectors: Perturbing or deleting any training point with Ξ±i=0\alpha_i = 0 (so long as it remains strictly outside the margin yif(xi)>1y_i f(x_i) > 1) causes ZERO change to the optimal hyperplane (wβˆ—,bβˆ—)(w^*, b^*)!

3. Mercer’s Theorem & Common Kernel Functions

A symmetric function K:XΓ—Xβ†’RK: \mathcal{X} \times \mathcal{X} \to \mathbb{R} is a valid kernel K(x,z)=βŸ¨Ο•(x),Ο•(z)⟩K(x, z) = \langle \phi(x), \phi(z) \rangle iff the Gram Matrix Gij=K(xi,xj)G_{ij} = K(x_i, x_j) is Positive Semi-Definite (PSD) (vTGvβ‰₯0v^T G v \ge 0) for every finite sample:

  • Polynomial Kernel (degree dd): K(x,z)=(xTz+c)dK(x, z) = (x^T z + c)^d (cβ‰₯0c \ge 0). For x∈Rpx \in \mathbb{R}^p, inhomogeneous (xTz+1)d(x^T z + 1)^d spans (p+dd)\binom{p + d}{d} monomial features in O(p)\mathcal{O}(p) dot-product time!
  • Gaussian RBF Kernel: K(x,z)=exp⁑(βˆ’Ξ³βˆ₯xβˆ’zβˆ₯22)K(x, z) = \exp(-\gamma \|x - z\|_2^2). As Ξ³β†’βˆž\gamma \to \infty (tiny bandwidth Οƒβ†’0\sigma \to 0), K(xi,xj)β†’I[i=j]K(x_i, x_j) \to \mathbb{I}[i = j], causing severe overfitting (island decision boundaries around each training sample).
Key Formulas Summary
Geometric Margin Between Canonical Hyperplanes
Ξ³=2βˆ₯wβˆ₯2,Hard-MarginΒ Primal:Β min⁑w,b12βˆ₯wβˆ₯22β€…β€ŠΒ s.t.Β β€…β€Šyi(wTxi+b)β‰₯1\gamma = \frac{2}{\|w\|_2}, \qquad \text{Hard-Margin Primal: } \min_{w,b} \frac{1}{2}\|w\|_2^2 \;\text{ s.t. }\; y_i(w^T x_i + b) \ge 1
Note: Maximizing margin 2/||w|| is equivalent to minimizing convex quadratic 1/2 ||w||^2
Soft-Margin SVM Dual & Support Vector Weight Expansion
maxβ‘Ξ±βˆ‘i=1nΞ±iβˆ’12βˆ‘i=1nβˆ‘j=1nΞ±iΞ±jyiyjK(xi,xj)s.t.Β 0≀αi≀C,β€…β€Šβˆ‘i=1nΞ±iyi=0\max_{\alpha} \sum_{i=1}^{n} \alpha_i - \frac{1}{2}\sum_{i=1}^{n}\sum_{j=1}^{n} \alpha_i \alpha_j y_i y_j K(x_i, x_j) \quad \text{s.t. } 0 \le \alpha_i \le C,\; \sum_{i=1}^{n} \alpha_i y_i = 0
Note: Optimal weight vector depends ONLY on support vectors (alpha_i > 0): w* = sum_i alpha_i y_i x_i
Gaussian RBF (Infinite-Dimensional) Kernel
KRBF(x,z)=exp⁑ ⁣(βˆ’Ξ³βˆ₯xβˆ’zβˆ₯22)=exp⁑ ⁣(βˆ’βˆ₯xβˆ’zβˆ₯222Οƒ2)K_{\text{RBF}}(x, z) = \exp\!\left(-\gamma \|x - z\|_2^2\right) = \exp\!\left(-\frac{\|x - z\|_2^2}{2\sigma^2}\right)
Note: Corresponds to an infinite-dimensional Hilbert feature space via Taylor expansion of e^(x^T z)
#Machine Learning#SVM#Kernel Trick#KKT#Hinge Loss#GATE DA#UGC NET CS

Practice Questions on This Chapter (2)

Q1GATE DA MLMCQMEDIUM
+2M β€’ -0.67

A hard-margin linear SVM in R2\mathbb{R}^2 learns the decision hyperplane 3x1+4x2βˆ’2=03x_1 + 4x_2 - 2 = 0 with canonical margin boundaries 3x1+4x2βˆ’2=Β±13x_1 + 4x_2 - 2 = \pm 1. What is the total geometric margin Ξ³\gamma between the two class support hyperplanes?

⚑ Click an option above to verify instantly
Q2GATE DA MLMCQEASY
+1M β€’ -0.33

In a trained Soft-Margin SVM, suppose a training point (xk,yk)(x_k, y_k) has dual Lagrange multiplier Ξ±k=0\alpha_k = 0. If (xk,yk)(x_k, y_k) is removed from the training set and the SVM is retrained, what happens to the optimal decision boundary?

⚑ Click an option above to verify instantly
Previous TopicMachine Learning: Bias-Variance, L1/L2 Regularization & Confusion Matrix MetricsNext Topic Decision Trees (Entropy vs Gini), Random Forests & Gradient Boosting (XGBoost)