The Concept of Margin
What you'll learn: You'll understand what the margin is in classification and why maximizing it leads to more robust decision boundaries.
What Is the Margin?
Imagine you're drawing a line to separate apples from oranges on a table. You could draw the line right next to the apples, barely avoiding them—but that seems risky. If someone nudges an apple slightly, it might end up on the wrong side!
The margin is the breathing room between your decision boundary and the nearest data points from each class. More formally, it's the perpendicular distance from the decision boundary to the closest training examples on either side.
Why the Margin Matters
When you have linear separability (which we covered in the previous lesson), you have infinitely many lines that can separate the classes. But not all lines are equally good:
- A small margin means your decision boundary is close to some training points—it's confident but fragile
- A large margin means your boundary has buffer space—it's more likely to generalize well to new, unseen data
Think of it like parking a car: you want maximum distance from the walls on both sides for safety.
The Support Vector Machine Goal
Support Vector Machines (which we're building toward) explicitly aim to find the decision boundary that maximizes this margin. The data points that lie exactly on the margin's edge—the closest ones to the boundary—are called support vectors, and they're the only points that matter for defining where the boundary sits.
Key Takeaway: The margin is the "safety zone" between your decision boundary and the nearest training examples; maximizing it typically produces more robust classifiers that generalize better.