Many separating lines 8 12 16 20 24 28 32 36 0 2 4 6 8 10 12 temperature, degrees sunny hours
The red circles are days when the ice cream sold out, the blue squares days when it did not. Countless lines can be drawn that try to separate the two classes. An SVM looks for the safest of them.
The decision boundary 8 12 16 20 24 28 32 36 0 2 4 6 8 10 12 temperature, degrees sunny hours
The thick line is the SVM's decision boundary. Days on one side count as sold out, days on the other as not.
The margin 8 12 16 20 24 28 32 36 0 2 4 6 8 10 12 temperature, degrees sunny hours
The dashed lines are the two edges of the margin: parallel to the boundary, at equal distance on both sides. The SVM places the boundary so that this strip is as wide as possible. A wide margin means fewer errors on new days.
Support vectors 8 12 16 20 24 28 32 36 0 2 4 6 8 10 12 temperature, degrees sunny hours
The 6 days with a yellow ring are the support vectors: those on the edge of the margin, inside it or on the wrong side. Only they decide the boundary. Drag a far-away day and the boundary does not move; drag a support vector and it shifts.
Soft margin 8 12 16 20 24 28 32 36 0 2 4 6 8 10 12 temperature, degrees sunny hours
These days may not be perfectly separable with a single line. A soft-margin SVM lets some days break the margin and pays a penalty for each. Right now 0 days are on the wrong side.
New day: sold out 8 12 16 20 24 28 32 36 0 2 4 6 8 10 12 temperature, degrees sunny hours
26 degrees, 6 hours of sun. Its score is 0.37, at or above zero: on the sold-out side of the boundary.
What C does 8 12 16 20 24 28 32 36 0 2 4 6 8 10 12 temperature, degrees sunny hours
C is the weight of the penalty for breaking the margin; now 1. A large C makes breaches expensive: the margin narrows and the model fits the training days tightly. A small C allows a wide margin and is less moved by odd days. Change C in the Try tab.
Why it matters 8 12 16 20 24 28 32 36 0 2 4 6 8 10 12 temperature, degrees sunny hours
Before deep learning, the SVM was among the strongest methods for text and image classification, and it still works well with little data. Its real strength is drawing curved boundaries with the kernel trick of the next topic.