Standard 4 stops to get here

Kernel Trick

Computing dot products in a huge feature space directly from the original inputs, so linear methods can learn nonlinear patterns cheaply.

Your route here

4 stops · basics first
  1. Machine Learning ✓ understood

    Building systems that learn patterns from data instead of following hand-written rules, getting better at a task as they see more examples.

  2. Supervised Learning ✓ understood

    Learning from examples paired with the correct answer, so a model can predict answers for new inputs it hasn't seen.

  3. Classification ✓ understood

    A supervised learning task where the model assigns each input to one of a fixed set of categories, such as spam or not spam.

  4. Support Vector Machine ✓ understood

    A supervised learning algorithm that finds the optimal hyperplane to separate classes with maximum margin.

  5. Kernel Trick · you are here ✓ understood

Picture it

Explicit features

  • Map each input to a big feature vector
  • Take dot products of those vectors
  • Cost grows with the feature space

Kernel trick

  • Never build the feature vectors
  • Compute k(x, x′) from the raw inputs
  • Same dot product, even if the space is infinite
Notice the answer is identical on both sides; the kernel just skips the expensive step of building the high-dimensional vectors.

The kernel trick lets a linear method draw curved boundaries without ever doing the expensive part. The idea: many algorithms, including the support vector machine, touch the data only through dot products between pairs of examples. If you replace every dot product with a kernel function k(x, x′) that equals a dot product in some richer feature space, the algorithm now works in that space, but you never compute the feature vectors themselves.

A concrete case: a polynomial kernel of degree p computes a dot product over all degree-p products of the input coordinates. Writing those products out explicitly would mean a vector that grows combinatorially with the input size. The kernel gets the same number from one dot product and a power. Some kernels go further and correspond to infinite-dimensional feature spaces, which could never be built explicitly at all; the widely used Gaussian (RBF) kernel is one.

Why it mattered

Linear methods are well understood: convex to train, with clean theory. The trick keeps all of that while letting the model fit nonlinear patterns, because the model is linear in the feature space and nonlinear in the original inputs. It is what lets support vector machines (the paper) separate classes that no straight line can, and it carries over to other methods that rely on dot products, such as kernel PCA and Gaussian processes.

The catch

Not every function is a valid kernel; it has to be positive definite, which guarantees a matching feature space exists. And kernel methods compare examples in pairs, so training builds an n × n matrix. That matrix grows with the square of the dataset, which makes kernel methods expensive on very large datasets. Neural networks take the opposite approach, learning their features rather than fixing them in advance through the choice of kernel.

Where it sits

Kernel Trick

Leads to

Nothing yet: a destination in its own right.

Explore nearby

Sources

  1. Thomas Hofmann, Bernhard Schölkopf and Alexander J. Smola, "Kernel Methods in Machine Learning" . Annals of Statistics 36(3), 2008; section 2.2 names the substitution the kernel trick