Support Vector Machines and the Kernel Trick
Another linear classifier — until the kernel trick quietly makes it not linear at all.
Advanced
lines_changed and
touches_slow_suite: many different straight lines could separate passes from
failures, but an SVM specifically picks the one positioned exactly in the middle of the gap
between the closest pass and the closest failure, as far from both as the data allows.
C controls how much that cost is weighed against margin width.
A large C penalizes violations heavily, producing a narrower margin that hugs the
training data closely (more variance, echoing
Overfitting vs Underfitting); a small
C tolerates more violations in exchange for a wider, smoother margin (more bias).
As with regularization's lambda, the right
value is found by sweeping candidates against a validation set, never guessed.
K(x, x') computes exactly what that dot product
would be if both points were first transformed into some higher-dimensional space — without
ever constructing that transformation explicitly. In the transformed space, a pattern that was
a ring in the original two features can become linearly separable by a flat plane; the kernel
delivers the benefit of that transformation at the computational cost of working in the
original, low-dimensional space.
| Kernel | What it captures |
|---|---|
| Linear | no transformation at all — equivalent to the plain margin-maximizing classifier described above |
| Polynomial | curved boundaries and feature interactions up to a chosen degree, similar in spirit to the polynomial regression from Linear Regression |
| RBF (Gaussian) | an implicit infinite-dimensional transformation — the default choice when there's no strong prior belief about the boundary's shape, and the most commonly used kernel in practice |
gamma, controlling how far a
single training point's influence reaches. A small gamma means each point
influences a wide region, producing a smooth, simple boundary (more bias); a large
gamma means influence drops off sharply, letting the boundary bend tightly around
individual points — including noisy ones (more variance). Between C and
gamma, an RBF SVM has two separate dials for the exact same bias/variance
tradeoff covered in Overfitting vs Underfitting,
and both are tuned together via the same cross-validation sweep from
Train/Test Splits & Cross-Validation, not
independently.
lines_changed
(ranging into the thousands) would swamp a 0/1 feature like touches_slow_suite in
that geometry, regardless of which one actually separates the classes better. The z-score
standardization from Feature Engineering, fit on the
training split only, is close to mandatory before fitting any SVM.
C and gamma.