svm() — Support Vector Machines
Finds the boundary with the widest gap between classes.
svm(X, y)
Key idea
- Pick the dividing line with the WIDEST gap (the margin) between the two groups. (e.g. margin = 2 / ||w||)
- Only the closest points — the support vectors — touch the gap and define the line.
- A soft margin allows a few points to slip across the gap, set by a cost setting.
- The kernel trick (a richer similarity measure) lets SVMs draw curved boundaries without heavy high-dimensional maths.
Definition
w,bmin 21∥w∥2s.t.yi(w⊤xi+b)≥1
- w
- the boundary direction
- margin=2/∥w∥
- the width of the gap
- yi
- the class label (+1 or -1)
In plain words
Don't just separate the two groups — leave the biggest possible no-man's-land down the middle.
Where you'd use it
- Text and image classification, especially with limited data.
- Bioinformatics problems with many features and few samples.
- Any task where a wide-margin, robust boundary matters.
Frequently asked questions
- What does an SVM do?
- Finds the widest-margin boundary between classes; the kernel lets that boundary bend.
- Why tune C and gamma?
- They trade margin width against fitting the training points — cross-validate to choose.