intermediateadvanced-ml

Support Vector Machines (SVM)

Draw the widest possible street between classes, not just any line that separates them.

Key Points

What it is

A Support Vector Machine finds the decision boundary (hyperplane) that separates classes with the maximum possible margin — the widest gap between the closest points of each class. Those closest points are called support vectors because they alone determine where the boundary sits.

Why it exists

Many lines can separate two classes perfectly on training data, but not all of them generalize equally well to new data. SVM exists to pick the one boundary that is maximally 'safe' — as far as possible from both classes — which tends to generalize better than an arbitrary separating line.

Intuition

Imagine drawing a road between two neighborhoods that never touches a house on either side. You could draw a narrow, winding road that barely squeezes through, or the widest possible straight road with the most breathing room on both sides. SVM always chooses the widest road — new houses built later are less likely to end up on the wrong side of it.

Formulas

Margin Maximization Objective

min⁡w,b12∥w∥2s.t. yi(w⋅xi+b)≥1\min_{w,b} \frac{1}{2}\|w\|^2 \quad \text{s.t. } y_i(w \cdot x_i + b) \geq 1
  • w, b — The weight vector and bias defining the separating hyperplane
  • \|w\|^2 — Minimizing this maximizes the margin width
  • y_i(w \cdot x_i + b) \geq 1 — Every point must be correctly classified and outside the margin

When to use

When not to use

Common mistakes

In practice

Common in text classification (spam detection, sentiment analysis with TF-IDF features), bioinformatics, and image classification tasks with a moderate number of samples, though largely replaced by gradient boosting and neural networks for very large datasets.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

kernel-tricklogistic-regressionfeature-scaling
Chirp at me!