Skip to content
E
Educatum

SVM

By Educatum AI teamLast updated: Original walkthrough ↗
Key Intuition

A Support Vector Machine (SVM) finds the maximum-margin hyperplane separating classes, relying solely on critical boundary points called support vectors. While a linear SVM scores samples via direct inner products in input space, an RBF (Gaussian) kernel SVM measures similarity as exp(-||x - x_c||^2 / (2 sigma^2)), implicitly mapping data into an infinite-dimensional feature space for non-linear decision boundaries.

Reference Diagram & Materials
SVM matrix calculation diagram

Linear vs. RBF Kernel SVM

The key operational difference between a linear SVM and an RBF kernel SVM lies in how similarity is measured between a test point xx and each support vector xcx_c:

  • Linear SVM:

    • Similarity measure: Direct inner (dot) product K(x,xc)=x⊤xcK(x, x_c) = x^\top x_c (equivalent to cosine similarity only when inputs are L2L_2-normalized).
    • Decision boundary: A linear hyperplane in the original input space.
  • RBF (Gaussian) Kernel SVM:

    • Similarity measure: Radial Basis Function kernel K(x,xc)=exp⁡ ⁣(−∥x−xc∥22σ2)=exp⁡ ⁣(−γ∥x−xc∥2)K(x, x_c) = \exp\!\left(-\frac{\|x - x_c\|^2}{2\sigma^2}\right) = \exp\!\left(-\gamma \|x - x_c\|^2\right)
    • When xx is close to xcx_c, ∥x−xc∥2→0  ⟹  K(x,xc)→1\|x - x_c\|^2 \to 0 \implies K(x, x_c) \to 1.
    • When xx is far from xcx_c, K(x,xc)→0K(x, x_c) \to 0.
    • Decision boundary: Smooth, non-linear boundary in input space (corresponding to a linear hyperplane in an implicit high-dimensional feature space).

Intuitive Explanation of Support Vectors

  • What they are: Support vectors are the subset of training points with non-zero dual weights (αi>0\alpha_i > 0) that directly determine the decision boundary:
    • In a hard-margin SVM (linearly separable data), support vectors are strictly the points closest to the separating hyperplane lying right on the margin (yi(w⊤xi+b)=1y_i(w^\top x_i + b) = 1).
    • In a soft-margin SVM (allowing slack ξi≥0\xi_i \ge 0 for noisy or non-separable data), support vectors include both points on the margin and points inside the margin or misclassified (yi(w⊤xi+b)≤1y_i(w^\top x_i + b) \le 1).
  • Why they are sufficient: Removing non-support-vector points (αi=0\alpha_i = 0) leaves the optimal boundary completely unchanged, whereas moving a support vector shifts the boundary.
  • Inference efficiency: At prediction time, the model only evaluates f(x)=∑i∈SVαiyiK(x,xi)+bf(x) = \sum_{i \in \text{SV}} \alpha_i y_i K(x, x_i) + b over the stored support vectors rather than the entire training dataset.

Why Does the Gaussian Kernel Map Data to an Infinite-Dimensional Space?

A valid kernel K(x,y)K(x, y) corresponds to an inner product ⟨ϕ(x),ϕ(y)⟩\langle \phi(x), \phi(y) \rangle in some feature space. Expand the Gaussian RBF kernel algebraically (setting σ=1\sigma = 1 for clarity, or keeping σ\sigma explicitly):

K(x,y)=exp⁡ ⁣(−∥x−y∥22σ2)=exp⁡ ⁣(−∥x∥22σ2)exp⁡ ⁣(−∥y∥22σ2)exp⁡ ⁣(x⊤yσ2)K(x, y) = \exp\!\left(-\frac{\|x - y\|^2}{2\sigma^2}\right) = \exp\!\left(-\frac{\|x\|^2}{2\sigma^2}\right) \exp\!\left(-\frac{\|y\|^2}{2\sigma^2}\right) \exp\!\left(\frac{x^\top y}{\sigma^2}\right)

Now expand exp⁡ ⁣(x⊤yσ2)\exp\!\left(\frac{x^\top y}{\sigma^2}\right) using its Taylor series:

exp⁡ ⁣(x⊤yσ2)=∑k=0∞(x⊤y)kσ2k k!\exp\!\left(\frac{x^\top y}{\sigma^2}\right) = \sum_{k=0}^{\infty} \frac{(x^\top y)^k}{\sigma^{2k}\, k!}

Each term (x⊤y)k(x^\top y)^k is proportional to an inner product over all degree-kk monomials of the input coordinates. Because the Taylor series contains infinitely many non-zero polynomial orders k=0,1,2,…k = 0, 1, 2, \dots, the implicit feature map ϕ(x)\phi(x) lives in an infinite-dimensional Hilbert space—yet the kernel trick evaluates ⟨ϕ(x),ϕ(y)⟩\langle \phi(x), \phi(y) \rangle in O(d)O(d) time directly in input space.

SVM linear vs RBF kernel diagram

More in GenAI by Hand

Try keywords like RoPE, FlashAttention, DPO, or Blind 75.