Support vector machine (SVM)
Supervised · Classification An SVM finds the boundary that separates two groups with the widest possible margin, the biggest empty gap on both sides. The points closest to the boundary are called support vectors, because they alone decide where it goes. When groups can't be split by a straight line, the kernel trick lets SVM draw curved boundaries.
Everyday analogy
Building the widest possible road between two villages, so houses on both sides stay as far from the traffic as possible.
Example
Used for: text and document classification, handwriting recognition, image classification, classifying genes and proteins.
The widest gap between two groups
How it works, step by step
- Plot the labelled examples as points.
- Look at all the lines (or planes) that could separate the two groups.
- Choose the one with the widest margin to the nearest points on each side.
- If no straight line can separate them, use a kernel to map the data into a higher dimension, where a clean split is possible.
- Classify a new point by which side of the boundary it falls on.
Worked example
Sorting customer emails into "complaint" and "enquiry". Each email becomes a point based on its words. The SVM finds the boundary with the widest gap between the two kinds, so even new emails with unusual wording are usually sorted correctly.
✓ Good for
- Accurate on small and medium datasets
- Works well with many features, such as text
- The wide margin helps it generalise to new data
⚠ Watch out for
- Slow on very large datasets
- Hard to explain individual decisions
- Choosing the right kernel and settings takes care
Try it yourself
About 10 minDraw the widest gap
- On paper, draw 6 dots of one colour on the left and 6 of another on the right.
- Draw several lines that separate them, then the one with the most space on both sides.
- Add a dot near the middle and see which line handles it best.
What you should see: SVM chooses the separating line with the widest safety margin.
Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.