Lesson 3.10core3 h

Support vector machines and kernels

The widest street, and the trick that makes it curve

SVMs were the dominant classifier before deep learning and remain excellent on small, clean datasets. More importantly, they teach three ideas you will meet again and again: maximizing a margin as a route to generalization, the dual view in which data enters only through inner products, and the kernel trick, which is the formal version of "similarity = dot product in some feature space" that underlies attention (7.2 Scaled dot-product and multi-head attention, fully derived) and embedding search (9.2 Embeddings deep dive).

You'll be able to

  • Derive the hard- and soft-margin SVM objectives from the geometry of the margin
  • Write the hinge-loss formulation and compare it with logistic loss
  • Explain the dual problem, support vectors and why predictions depend on data only through inner products
  • Apply the kernel trick (polynomial, RBF), tune C and γ, and know when to use linear vs kernel SVMs

Key ideas

  1. The SVM picks the separating hyperplane with the largest margin 2/‖w‖; maximizing the margin = minimizing ½‖w‖² under yᵢ(wᵀxᵢ + b) ≥ 1.
  2. Soft margins add slack; the problem equals hinge loss Σ max(0, 1 − yᵢf(xᵢ)) plus L2 regularization 1/(2C)·‖w‖².
  3. Large C → narrow margin, few violations, high variance; small C → wide margin, more violations, higher bias.
Show 4 more key ideas
  1. In the dual, w = Σ αᵢyᵢxᵢ and only support vectors (points on or inside the margin) have αᵢ > 0.
  2. Predictions depend on data only through inner products, so any PSD kernel k(x, z) = φ(x)ᵀφ(z) can replace them — the kernel trick.
  3. RBF kernel exp(−γ‖x−z‖²) is an infinite-dimensional feature map; γ controls locality and overfitting.
  4. Scale features, tune C and γ on log grids by CV, and switch to linear SVMs beyond ~10⁵ samples.

Suggested path through this lesson