Kernel Methods and Gaussian Processes — The Champions Before Neural Nets
Before deep learning took over, kernel SVMs held the crown in classification. This article builds the whole story from zero: the kernel trick that makes lifting into high dimensions free, Gaussian processes that put a probability distribution over functions, and Bayesian optimization that turns uncertainty into a weapon.
Practical Bayesian Optimization of Machine Learning Algorithms
Primary source — what this article is built on
undefined2026-08-27
Practical Bayesian Optimization of Machine Learning AlgorithmsarXiv:1206.2944Paper page·PDFA Tutorial on Bayesian Optimization of Expensive Cost FunctionsarXiv:1012.2599Paper page·PDF
Deep Neural Networks as Gaussian ProcessesarXiv:1711.00165Paper page·PDF
Neural Tangent Kernel: Convergence and Generalization in Neural NetworksarXiv:1806.07572Paper page·PDF
A problem a single ruler cannot cut
Picture red and blue markers scattered on a table. The red ones cluster in the middle; the blue ones form a ring around them. Now lay down a single ruler and separate red from blue cleanly. You can't. A straight line has no way to carve out an enclosed interior.
But grab the tablecloth by its center and lift. The red markers rise; the blue ones stay low. Slide a flat board in horizontally, and a single perfectly straight cut separates the two colors.
That is where kernel methods begin. A problem that seems to demand a curved boundary becomes straight-line separable once you lift the data into a higher-dimensional space. And the real subject of this article is the second half of that sentence: how to make the lifting cost nothing.
Write the lift down explicitly and the dimensions explode
The lifting operation is a function called a feature map, written . It takes an input and moves it into a different, higher-dimensional space.
For the ring above, mapping the 2D point to is enough. The third coordinate is the squared distance from the origin, so the center markers sit low and the outer ring sits high — exactly the lifted tablecloth.
The trouble starts when you don't know in advance how the boundary curves. If you play it safe and lift exhaustively — "include every term up to degree three" — the dimension grows combinatorially. From features, the number of degree-three terms is , which for is 167,167,000. Transforming a single data point would produce 167 million numbers, and holding that for tens of thousands of points is not something you do.
The trick: only the inner product matters
Here is the observation that changes everything. Most classification and regression algorithms never actually need itself. What they need is "how similar are and " — that is, the inner product of two vectors, and nothing more.
The inner product as a yardstick for similarity is the same idea that drives Attention from Scratch: vectors pointing in the same direction have a large dot product. That is what "similar" means mathematically.
So let's define that inner product as a function in its own right.
is called a kernel function. The left side takes and and returns a single number; the right side is "lift both into high dimensions, then take the inner product." What the equation claims is this: if you can find a convenient that makes both sides equal, you never have to compute at all.
Does such a convenient function exist? It does. Expand and you get exactly the inner product of two vectors listing every term up to degree three. The left side costs multiplications and additions plus one cubing. The right side is a 167-million-dimensional inner product. Same value, but one of them lands instantly. That is the kernel trick.
Not every function qualifies as a kernel
For to be writable as "the inner product of some ," it must be positive definite. Pick any finite set of points ; the matrix — the Gram matrix, or kernel matrix — must be positive semi-definite. If that holds, a corresponding is guaranteed to exist, even if it is infinite-dimensional (Mercer's theorem).
The flip side matters in practice. If you invent a similarity function off the top of your head and drop it in, this condition can break, and you get diverging optimization or a failed Cholesky factorization further downstream. The safe way to build a custom kernel is to compose known ones: sums, products, and positive scalar multiples of kernels are again kernels.
In practice, four kernels cover nearly everything.
- Linear — no lifting, just the raw inner product
- Polynomial — captures interactions up to degree
- RBF (Gaussian) — its is infinite-dimensional
- Matérn — lets you dial the smoothness of the function directly via
The intuition for RBF is "similarity that equals 1 at zero distance and falls off fast." Here (length_scale) is the yardstick for how far apart two points must be before they count as strangers: small gives a wiggly boundary, large a bland one. scikit-learn's SVM specifies the same quantity as its reciprocal, , so raising gamma makes the model more flexible while raising length_scale makes it smoother — the two run in opposite directions, which is an easy thing to get backwards.
Comments
Sign in to comment