TAI BUI
Back to curriculum
BuildPython

Support Vector Machines

Find the widest street between two classes. That's the entire idea.

TIME: ~90 minutesPREREQUISITES: Phase 1 (Lessons 08 Optimization, 14 Norms and Distances, 18 Convex Optimization)

Learning Objectives

  • Implement a linear SVM from scratch using hinge loss and gradient descent on the primal formulation
  • Explain the maximum margin principle and identify support vectors from a trained model
  • Compare linear, polynomial, and RBF kernels and explain how the kernel trick avoids explicit high-dimensional mapping
  • Evaluate the tradeoff controlled by the C parameter between margin width and classification errors

The Problem

You have two classes of points and need to draw a line, or a hyperplane once you're past two dimensions, that separates them. Infinitely many lines will do the job. Which one should you pick?

The one with the widest margin. Margin is the distance between the decision boundary and the closest point on either side. Push the boundary as far from both classes as it will go, and you get a classifier that's more confident on the training data and holds up better on points it hasn't seen.

That single idea is the whole Support Vector Machine. Maximize the margin, and the boundary falls out of the math with nothing else bolted on. SVMs ran classification before deep learning took over, and for small datasets, high-dimensional data, or anywhere you want a model with real theoretical guarantees instead of a black box, they still win.

They also lean directly on Phase 1: the optimization is convex (Lesson 18), the margin is measured with norms (Lesson 14), and the kernel trick runs entirely on dot products to handle nonlinear boundaries without ever computing in the high-dimensional space.

Warm-up0/3
1. What is the Euclidean length (norm) of the vector [3, 4]?Warm-up
A grid with an arrow from the origin to the point (3, 4), dashed legs along the x axis and up to the tip, and a question mark by the arrow for its length.
Drawn to scale.
2. What is the dot product of [1, 2, 3] and [4, 5, 6]?Warm-up
Two rows of three boxes: a holds 1, 2, 3 and b holds 4, 5, 6, with a question mark for a dot b.
3. What does it mean for an optimization problem to be convex?Warm-up
A bowl-shaped curve f of w with two points on it joined by a dashed straight segment.
Illustrative curve y = w squared.

The Concept

The maximum margin classifier

Start with linearly separable data: labels y_i in {-1, +1}, feature vectors x_i. We want a hyperplane w^T x + b = 0 that separates the two classes.

The distance from a point x_i to that hyperplane is:

distance = |w^T x_i + b| / ||w||

A correctly classified point satisfies y_i * (w^T x_i + b) > 0, and the margin is twice the distance from the hyperplane to the nearest point on either side.

Mermaid diagram

Maximizing the margin gives this optimization problem:

maximize    2 / ||w||     (the margin width)
subject to  y_i * (w^T x_i + b) >= 1  for all i

Flip it to minimizing ||w||^2 instead, and you get the same answer out of friendlier math:

minimize    (1/2) ||w||^2
subject to  y_i * (w^T x_i + b) >= 1  for all i

That's a convex quadratic program, so it has one global solution with no local minima hiding anywhere. The points sitting exactly on the margin boundary, where y_i * (w^T x_i + b) = 1, are the support vectors. They're the only points that matter: move or delete any other point and the boundary doesn't move.

Support vectors: the critical few

Mermaid diagram

Most of your training data is dead weight. Only the points touching the margin, the support vectors, decide where the boundary sits. That's also why SVMs are cheap to store at prediction time: keep the support vectors, throw away the rest of the training set.

The count of support vectors doubles as a rough bound on generalization error. Fewer support vectors relative to your dataset size means the model is leaning on less of the data to make its call, and it tends to generalize better.

Soft margin: handling noise with the C parameter

Real data is rarely perfectly separable. Some points end up on the wrong side of the boundary, or inside the margin itself. The soft margin formulation tolerates that by adding slack variables.

minimize    (1/2) ||w||^2 + C * sum(xi_i)
subject to  y_i * (w^T x_i + b) >= 1 - xi_i
            xi_i >= 0  for all i

Each slack variable xi_i measures how badly point i violates the margin, and C controls how much of that you're willing to tolerate:

C valueBehavior
Large CPenalizes violations heavily. Narrow margin, fewer misclassifications. Overfits
Small CAllows more violations. Wide margin, more misclassifications. Underfits

Think of C as regularization strength running backwards: turn it up and you get less regularization, turn it down and you get more.

Hinge loss: the SVM loss function

Drop the constraints and the soft margin SVM turns into an unconstrained optimization:

minimize    (1/2) ||w||^2 + C * sum(max(0, 1 - y_i * (w^T x_i + b)))

That max(0, 1 - y_i * f(x_i)) term is the hinge loss. It's zero once a point is correctly classified and clear of the margin, and it climbs in a straight line the moment that point drifts inside the margin or gets misclassified.

Hinge loss for a single point:

loss
  |
  | \
  |  \
  |   \
  |    \
  |     \_______________
  |
  +-----|-----|-------->  y * f(x)
       0     1

Zero loss when y*f(x) >= 1 (correctly classified, outside margin).
Linear penalty when y*f(x) < 1.

Line it up against logistic loss, the one behind logistic regression:

Hinge:     max(0, 1 - y*f(x))          Hard cutoff at margin
Logistic:  log(1 + exp(-y*f(x)))        Smooth, never exactly zero

Hinge loss is sparse: only the support vectors contribute anything nonzero to the solution. Logistic loss has no such cutoff, every point pulls its weight, which is exactly why SVMs end up cheaper to store at prediction time.

Training a linear SVM with gradient descent

Skip the constrained QP solver entirely, and you can train a linear SVM with plain gradient descent on hinge loss plus L2 regularization:

L(w, b) = (lambda/2) * ||w||^2 + (1/n) * sum(max(0, 1 - y_i * (w^T x_i + b)))

Gradient with respect to w:
  If y_i * (w^T x_i + b) >= 1:  dL/dw = lambda * w
  If y_i * (w^T x_i + b) < 1:   dL/dw = lambda * w - y_i * x_i

Gradient with respect to b:
  If y_i * (w^T x_i + b) >= 1:  dL/db = 0
  If y_i * (w^T x_i + b) < 1:   dL/db = -y_i

This is the primal formulation, and it runs in O(n * d) per epoch, n samples and d features. On large, sparse, high-dimensional data like text classification, that's fast enough to matter.

The dual formulation and the kernel trick

Take the Lagrangian dual of the SVM problem (Phase 1 Lesson 18 covers the KKT conditions behind it):

maximize    sum(alpha_i) - (1/2) * sum_ij(alpha_i * alpha_j * y_i * y_j * (x_i . x_j))
subject to  0 <= alpha_i <= C
            sum(alpha_i * y_i) = 0

Notice what's actually in there: nothing but dot products x_i . x_j between data points. That's the whole trick. Swap every dot product for a kernel function K(x_i, x_j) and the SVM learns nonlinear boundaries without ever explicitly building the transformed feature space.

Linear kernel:      K(x, z) = x . z
Polynomial kernel:  K(x, z) = (x . z + c)^d
RBF (Gaussian):     K(x, z) = exp(-gamma * ||x - z||^2)

The RBF kernel sends data into an infinite-dimensional space: points close together in the input get a kernel value near 1, points far apart get a value near 0, and the boundary it learns can bend around almost any smooth shape.

Mermaid diagram

What makes this worth caring about: the kernel trick computes a dot product from the high-dimensional space without ever visiting it. A degree-d polynomial kernel in D dimensions implies a feature space with O(D^d) dimensions, yet K(x, z) itself costs only O(D) to compute.

SVM for regression (SVR)

Support Vector Regression takes the same margin idea and fits a tube of width epsilon around the data instead of a boundary between classes. Land inside the tube and it costs nothing; land outside it and the penalty grows linearly with the miss.

minimize    (1/2) ||w||^2 + C * sum(xi_i + xi_i*)
subject to  y_i - (w^T x_i + b) <= epsilon + xi_i
            (w^T x_i + b) - y_i <= epsilon + xi_i*
            xi_i, xi_i* >= 0

Epsilon sets the tube's width, and it's a direct dial on the fit: wider tube, fewer support vectors, smoother curve; narrower tube, more support vectors, tighter fit.

Why SVMs lost to deep learning (and when they still win)

SVMs owned machine learning from the late 1990s through the early 2010s. Deep learning eventually passed them, and the reasons all trace back to scale and raw data:

FactorSVMsDeep learning
Feature engineeringRequires itLearns features
ScalabilityO(n^2) to O(n^3) for kernelO(n) per epoch with SGD
Image/text/audioNeeds handcrafted featuresLearns from raw data
Large datasets (>100k)SlowScales well
GPU accelerationLimited benefitMassive speedup

But SVMs still win outright in these situations:

  • Small datasets (hundreds to low thousands of samples)
  • High-dimensional sparse data (text with TF-IDF features)
  • When you need mathematical guarantees (margin bounds)
  • When training time must be minimal (linear SVM is very fast)
  • Binary classification with clear margin structure
  • Anomaly detection (one-class SVM)
Check: The Concept0/28
1. What are support vectors in an SVM?Define
A scatter of 14 points in two classes, circles and squares, separated by a solid straight decision boundary.
Synthetic points; boundary computed with numpy.
2. What does the SVM maximize when finding the decision boundary?Define
A scatter of 16 points in two classes with three different straight lines labelled L1, L2, L3, each separating the two classes.
Synthetic points; lines computed with numpy.
3. In an SVM, what is the margin?Define
A scatter of 16 points in two classes separated by a solid straight boundary, with the text margin equals question mark.
Synthetic points; boundary computed with numpy.
4. Hinge loss max(0, 1 - y*f(x)) is zero when y * f(x) >= 1. What does that tell you about the point?Define
A plot of hinge loss against y times f of x from -2 to 3: a straight line falling from the left down to zero at 1, then flat at zero. Dotted verticals mark 0 and 1.
Plot of max(0, 1 - y*f(x)).
5. What does the C parameter control in a soft margin SVM?Define
A scatter of 40 overlapping points in two classes with a solid straight boundary, and the text C equals question mark.
Synthetic points; fit computed with numpy.
6. What is a soft margin SVM?Define
A scatter of 36 overlapping points in two classes with a solid straight line through the mixed region; some points sit on the wrong side of it.
Synthetic points; boundary computed with numpy.
7. What does the slack variable xi_i represent in the soft margin SVM formulation?Define
A scatter of 28 points in two classes with a boundary and a shaded band around it. One point is circled and named point i, with the text xi sub i equals question mark.
Synthetic points; fit computed with numpy.
8. What does the dual formulation of the SVM optimization problem depend on?Define
The dual objective written out with the term inside the double sum replaced by a question mark, above a list of three training points with labels.
Typed example points.
9. What is the kernel trick?Define
A number line from -4 to 4 with class +1 circles at -1, 0 and 1 and class -1 squares at -3, -2, 2 and 3.
Typed example data.
10. What is the linear kernel K(x, z)?Define
A grid with two arrows from the origin, x equal to 2, 1 and z equal to 1, 3, beside the text linear kernel K of x, z equals question mark.
Drawn to scale.
11. What does the polynomial kernel (x . z + c)^d implicitly give the SVM?Define
Two 2-D input vectors and the polynomial kernel (x . z + c)^d with d equal to 2, with a question about what the implied feature vector contains.
Typed setup.
12. What does the RBF kernel value K(x, z) = exp(-gamma * ||x - z||^2) tell you about two points?Define
A plane with an anchor point x, a point z1 close to it and a point z2 far from it, with squared distances 0.25 and 13 and the RBF kernel values left as question marks.
Drawn to scale.
13. In Support Vector Regression (SVR), what happens to training points that fall inside the epsilon-tube?Define
A scatter of 18 points with a fitted regression line, a shaded tube of half-width epsilon around it, and a question about the loss of points inside the tube.
Synthetic data; SVR fit computed with numpy.
14. How does the RBF kernel formula differ from the polynomial kernel formula?Explain
Two arrows from the origin, x equal to 2, 0 and z equal to 0, 1, with their dot product 0 and squared distance 5 listed, and the polynomial and RBF kernel values left as question marks.
Drawn to scale.
15. Why is the SVM objective written as minimizing (1/2)||w||^2 rather than maximizing 2/||w||?Explain
Two panels with a vertical boundary and a shaded gap between the lines at plus and minus 1: for the length of w equal to 1 the gap is 2 wide, for 2 it is 1 wide.
Computed by script.
16. Why can a trained SVM throw away most of its training set before making predictions?Explain
A scatter of 40 points in two classes separated by a solid boundary, with a question about what the model must store to predict.
Synthetic points; boundary computed with numpy.
17. Two SVMs reach similar training accuracy on 1,000 points. One keeps 30 support vectors and the other keeps 600. Which is expected to generalize better, and why?Explain
Two bars of length 1,000: Model 1 filled for 30 support vectors, Model 2 filled for 600, with a note that both reach similar training accuracy.
Bars drawn to scale.
18. Why does hinge loss lead to a sparse solution while logistic loss does not?Explain
The hinge and logistic loss formulas above a one-row table of seven values of y times f of x: 2.4, 1.8, 1.3, 0.6, 0.2, -0.5 and 3.1.
Typed example values.
19. In SVR, what is the effect of widening the epsilon tube?Explain
A scatter of 50 noisy sine-shaped points with a fitted curve and a narrow shaded tube around it, and a question about widening the tube.
Synthetic data; RBF SVR (gamma 1, C 5) computed with numpy.
20. Why is a degree-d polynomial kernel cheap to compute even though its implied feature space has O(D^d) dimensions?Explain
Two rows of ten boxes for vectors x and z, the polynomial kernel with d equal to 3, the implied feature space of about 1000 dimensions, and a question about the work to evaluate the kernel.
Illustrative sizes D = 10 and d = 3.
21. How does C relate to regularization strength?Explain
Two boxes: the familiar lambda penalty where raising lambda adds regularization, and the soft margin objective with C where raising C gives a question mark.
Typed comparison.
22. Why did deep learning surpass SVMs for tasks like image and text classification?Explain
A small 8 by 8 pixel image of a digit and a line of raw text, each with an arrow to an SVM box and to a deep network box, each followed by needs: question mark.
Typed pixel pattern for illustration.
23. In the primal gradient descent training of a linear SVM, what is dL/dw when a point satisfies y_i * (w^T x_i + b) >= 1?Explain
The lesson's regularized hinge loss written out, a stated case where y_i times (w transpose x_i plus b) is at least 1, and dL/dw left as a question mark.
Formula as written in the lesson.
24. Your SVM fits the training data almost perfectly but performs much worse on held-out data, and you suspect C is set too high. What would you expect to see in the trained model?Analyze
Two schematic bars: training accuracy nearly full and held-out accuracy much shorter, with a suspicion that C is set too high and a question about the trained model.
Schematic; bar lengths are not measured.
25. A linear SVM scores near chance on two concentric rings of points, even with a well-chosen C. What is the right diagnosis?Analyze
A scatter of 160 points in two concentric rings, inner circles and outer squares coloured by class, with one straight line through the middle; the accuracy is 63%.
Synthetic points; fit computed with numpy.
26. After setting C = 0.001, an SVM has low training accuracy and many points sitting inside a very wide margin. What is the most likely diagnosis?Analyze
A scatter of 44 points in two classes with a very wide shaded band around a boundary; 44 of the 44 points lie inside the band and the training accuracy is 75%.
Synthetic points; fit computed with numpy.
27. You have 800 samples whose classes form a curved, ring-like pattern, and you want a nonlinear boundary. Which approach is best?Design
A scatter of 150 sampled points from 800 in two classes forming an inner cluster and an outer ring, with the goal of a nonlinear boundary.
Synthetic points; 150 of the 800 are drawn.
28. You are predicting a continuous value, errors under 0.5 units do not matter to you, and you want a compact model with few support vectors. Which design fits?Design
A scatter of 40 points showing a rising trend with noise, a small green bracket marking 0.5 units of vertical error, and notes about wanting a compact model.
Synthetic data.

Build It

Step 1: Hinge loss and gradient

Everything else in this build rests on this one function: hinge loss for a batch, plus its gradient.

python
def hinge_loss(X, y, w, b):
    n = len(X)
    total_loss = 0.0
    for i in range(n):
        margin = y[i] * (dot(w, X[i]) + b)
        total_loss += max(0.0, 1.0 - margin)
    return total_loss / n

Step 2: Linear SVM via gradient descent

Train by minimizing regularized hinge loss directly. No QP solver, no dual, just gradient descent.

python
class LinearSVM:
    def __init__(self, lr=0.001, lambda_param=0.01, n_epochs=1000):
        self.lr = lr
        self.lambda_param = lambda_param
        self.n_epochs = n_epochs
        self.w = None
        self.b = 0.0
 
    def fit(self, X, y):
        n_features = len(X[0])
        self.w = [0.0] * n_features
        self.b = 0.0
 
        for epoch in range(self.n_epochs):
            for i in range(len(X)):
                margin = y[i] * (dot(self.w, X[i]) + self.b)
                if margin >= 1:
                    self.w = [wj - self.lr * self.lambda_param * wj
                              for wj in self.w]
                else:
                    self.w = [wj - self.lr * (self.lambda_param * wj - y[i] * X[i][j])
                              for j, wj in enumerate(self.w)]
                    self.b -= self.lr * (-y[i])
 
    def predict(self, X):
        return [1 if dot(self.w, x) + self.b >= 0 else -1 for x in X]

Step 3: Kernel functions

Linear, polynomial, and RBF, each as a plain function.

python
def linear_kernel(x, z):
    return dot(x, z)
 
def polynomial_kernel(x, z, degree=3, c=1.0):
    return (dot(x, z) + c) ** degree
 
def rbf_kernel(x, z, gamma=0.5):
    diff = [xi - zi for xi, zi in zip(x, z)]
    return math.exp(-gamma * dot(diff, diff))

Step 4: Margin and support vector identification

Once it's trained, pull out which points landed on the margin and measure how wide that margin actually is.

python
def find_support_vectors(X, y, w, b, tol=1e-3):
    support_vectors = []
    for i in range(len(X)):
        margin = y[i] * (dot(w, X[i]) + b)
        if abs(margin - 1.0) < tol:
            support_vectors.append(i)
    return support_vectors

The full implementation, with every demo, lives in code/svm.py.

Check: Build It0/6
1. Using hinge_loss with w = [1, 1], b = 0, X = [[2, 1], [0.5, 0.2]] and y = [1, 1], what does it return?Apply
A plane with the line x plus y equal to 0, dashed lines at plus and minus 1, and two class +1 points P1 at (2, 1) and P2 at (0.5, 0.2), with the inputs listed and the loss left as a question mark.
Drawn to scale.
2. A fresh LinearSVM (w = [0, 0], b = 0, lr = 0.001) processes the point x = [1, 2] with y = -1. After that single update, what are w and b?Apply
The lesson's update rule for one step shown as code, with the starting values w = [0, 0], b = 0, lr = 0.001, the point x = [1, 2] with y = -1, and the result left as question marks.
Code abridged from the lesson.
3. With w = [2, -1] and b = -1, what does predict return for the single point x = [1, 1]?Apply
A plane with a line through (1, 1) for w = [2, -1], b = -1, a marked point x = [1, 1], and the output of predict left as a question mark.
Drawn to scale.
4. What does polynomial_kernel([1, 2], [3, 1], degree=2, c=1.0) return?Apply
A grid with two arrows from the origin, x equal to 1, 2 and z equal to 3, 1, and a call to polynomial_kernel with degree 2 and c 1.0 whose result is a question mark.
Drawn to scale.
5. What does rbf_kernel([0, 0], [1, 1], gamma=0.5) return, to two decimals?Apply
A plane with two points, [0, 0] and [1, 1], and a call to rbf_kernel with gamma 0.5 whose result, to two decimals, is a question mark.
Drawn to scale.
6. find_support_vectors is run with w = [1, 0], b = 0, tol = 1e-3 on X = [[1, 0], [2, 0], [1.0005, 3]] and y = [1, 1, 1]. What does it return?Apply
A plane with the vertical line x1 equal to 0 and three class +1 points: index 0 at [1, 0], index 1 at [2, 0], index 2 at [1.0005, 3], and the returned list left as a question mark.
Drawn to scale.

Use It

In practice you'll rarely write your own SVM. Here's the scikit-learn version:

python
from sklearn.svm import SVC, LinearSVC, SVR
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
 
clf = Pipeline([
    ("scaler", StandardScaler()),
    ("svm", SVC(kernel="rbf", C=1.0, gamma="scale")),
])
clf.fit(X_train, y_train)
print(f"Accuracy: {clf.score(X_test, y_test):.4f}")
print(f"Support vectors: {clf['svm'].n_support_}")

One rule you cannot skip: scale your features first. The margin depends on ||w||, so if one feature ranges into the thousands and another sits between 0 and 1, the geometry is already lying to you before training even starts.

Once your dataset gets large, reach for LinearSVC instead of SVC. LinearSVC runs the primal formulation at O(n) per epoch; SVC's dual formulation costs O(n^2) to O(n^3), which gets painful fast:

python
from sklearn.svm import LinearSVC
 
clf = Pipeline([
    ("scaler", StandardScaler()),
    ("svm", LinearSVC(C=1.0, max_iter=10000)),
])
Check: Use It0/4
1. Why must you scale features before training an SVM, and when should you use LinearSVC instead of SVC?Explain
A three-row table where column A holds values in the thousands and column B holds values between 0 and 1, followed by two question marks about scaling and about SVC versus LinearSVC.
Illustrative values, typed.
2. An SVM is trained on a column that ranges from 0 to 5,000 and another that ranges from 0 to 1, and it behaves as if only the large column matters. What went wrong?Analyze
A scatter of 120 points drawn with equal units on both axes: they spread from 0 to 5,000 across column 1 but sit flat along the bottom because column 2 only spans 0 to 1.
Synthetic data.
3. SVC with a linear kernel takes hours on 500,000 rows. Which explanation and fix fit best?Analyze
A short code box creating an SVC with a linear kernel and calling fit on 500,000 rows, followed by a line saying it is still running after hours.
Typed example, not captured.
4. You must classify 200,000 documents represented as sparse TF-IDF vectors with tens of thousands of features, and training time matters. Which setup fits best?Design
A large rectangle for 200,000 document rows by tens of thousands of TF-IDF feature columns, almost empty with a few scattered dots for nonzero entries.
Schematic; dot positions are random, not real data.
Author's Note

The part of this lesson that actually trips people up in practice isn't the math, it's gamma on the RBF kernel. C gets all the attention because every textbook frames it as the tuning knob, but on real data I've burned more debugging time on a badly chosen gamma than a badly chosen C. Too high, and every training point turns into its own support vector, memorizing noise instead of learning a boundary. Too low, and the model can barely tell the classes apart. Grid search both together. Never tune one and leave the other at its default.

The other thing worth saying out loud: by 2026 you'll reach for an SVM less often than the space it takes up in a curriculum suggests. Gradient boosted trees beat it on almost anything tabular, and neural nets beat it on anything with real structure. Where it still earns its keep is small, clean, high-dimensional datasets, one-class anomaly detection, and any spot where you need a model whose behavior you can actually reason about instead of just trust. Learn it cold anyway. The dual formulation and the kernel trick resurface the moment you start reading papers on kernel methods, Gaussian processes, or kernelized RL, and half the intuition for why the kernel trick even works traces straight back to this lesson.

Exercises

  1. Generate a 2D linearly separable dataset. Train your LinearSVM and identify the support vectors. Verify that the support vectors are the points closest to the decision boundary.

  2. Vary C from 0.001 to 1000 on a noisy dataset. Plot the decision boundary for each C value. Observe the transition from wide margin (underfitting) to narrow margin (overfitting).

  3. Create a dataset where class boundaries are circular (not linear). Show that a linear SVM fails. Compute the RBF kernel matrix and show that the classes become separable in the kernel-induced feature space.

  4. Compare hinge loss vs logistic loss on the same dataset. Train a linear SVM and logistic regression. Count how many training points contribute to each model's decision boundary (support vectors vs all points).

  5. Implement SVR (epsilon-insensitive loss). Fit it to y = sin(x) + noise. Plot the epsilon tube around the predictions and highlight the support vectors (points outside the tube).

Key Terms

TermWhat people sayWhat it actually means
Support vectors"The important data points"The training points closest to the decision boundary. The only points that determine the hyperplane
Margin"How confident the model is"The distance between the decision boundary and the nearest support vectors. SVMs maximize this
Hinge loss"The SVM's error function"max(0, 1 - y*f(x)). Zero when correctly classified and outside the margin. Linear penalty otherwise
C parameter"The regularization knob"Trade-off between margin width and classification errors. Large C = narrow margin, small C = wide margin
Soft margin"Allowing some mistakes"SVM formulation that allows margin violations via slack variables. Handles non-separable data
Kernel trick"Making the data separable"Computing dot products in a high-dimensional feature space without explicitly mapping to that space
Linear kernel"No transformation, just similarity"K(x, z) = x . z. Equivalent to standard dot product. For linearly separable data
RBF kernel"The kernel that works on anything"K(x, z) = exp(-gamma * ||x-z||^2). Maps to infinite dimensions. Learns any smooth boundary
Polynomial kernel"Curvy decision boundaries"K(x, z) = (x . z + c)^d. Maps to a feature space of polynomial combinations
Dual formulation"The other way to solve it"Reformulation of the SVM problem that depends only on dot products between data points. Enables kernels
SVR"SVM, but for regression"Support Vector Regression. Fits an epsilon-tube around the data. Points inside the tube have zero loss
Slack variables"How far a point crossed the line"xi_i: measures how much a point violates the margin. Zero for correctly classified points outside margin
Maximum margin"The widest possible gap"The principle of choosing the hyperplane that maximizes the distance to the nearest points of each class

Further Reading

Code

Ships With