← All AI/ML articles

Support vector machines, visualised.

Many lines can split two classes. An SVM picks the one with the widest empty street on either side. See which points hold that street up, then bend it with a kernel.

1. Widest margin2. Trade margin for errors (C)3. Bend it with a kernel
class Aclass Bring = support vector
Click to add a point of the chosen class. Double-click a point to remove it. The solid white line is the boundary, the faint lines are the margins.
Train accuracy0
Test accuracy0
Support vectors0
Verdict-
Behind the scenes · 1

Only a few points matter

After training, every point gets a weight α. Most are exactly zero. The points with α > 0 are the support vectors: they sit on or inside the margin and hold the boundary in place. Press Keep only SVs in the lab and the boundary will not move.



Behind the scenes · 2

C: how much to forgive

Real data overlaps, so a perfect street is impossible. C sets the price of a point on the wrong side. Small C tolerates mistakes and keeps the street wide. Large C punishes every mistake and squeezes the street to fit. Train accuracy climbs with C while test accuracy peaks and may slip. Click the chart to try a C.


Cyan = train, pink = test, at your current kernel and γ. The white line marks your current C.

Behind the scenes · 3

Bending the boundary: the RBF kernel

A kernel measures similarity between two points. The RBF kernel, exp(−γ·distance²), makes each support vector a bump of influence. γ sets the bump width: small γ gives broad, smooth boundaries, large γ gives tiny islands around single points. This table refits at every γ with your current C. Click a row to use it.



Too small a γ and the boundary is almost straight (underfit). Too large and it memorises the training points (overfit). Tune γ and C together using test accuracy.

Experiment

Break it on purpose

Underfit it

A ring of points with a linear kernel. A straight line cannot enclose a circle, so accuracy stays near a coin flip.

Overfit it

Overlapping clusters with RBF, huge γ and huge C. The boundary draws an island around every point.

Calm it down

Same data, but a gentler γ and a smaller C. The islands merge into one smooth boundary.

Check yourself

Three quick questions

Key takeaways

  • An SVM chooses the boundary with the widest margin between the two classes.
  • Support vectors are the few points on or inside the margin. Only they define the boundary.
  • C trades margin width against training mistakes: small C is forgiving, large C is strict.
  • Kernels let a linear method draw curved boundaries. With RBF, γ sets how local each point's influence is.
  • Large C and large γ together overfit. Judge settings on test accuracy.
← Back to all articles