Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Lift it, then cut it straight
Scatter red marbles in a ring around blue marbles on a table. No straight line separates them. Now push the middle of the tablecloth up: the blue marbles rise, the red ones stay low, and a flat sheet slid in between separates them perfectly. That’s a feature map: add new coordinates (here, height = distance from the centre squared) so that a straight cut works.
The kernel trick is the surprise: many learning algorithms only ever ask “how similar are these two points?”, meaning an inner product. If you can compute that similarity directly in the lifted space, you never need to build the lifted coordinates at all.
Kernel methods (SVMs, Gaussian processes, kernel ridge regression) remain the method of choice for small, precious datasets: terrain classification from a few labelled patches, system identification for control, and surrogate models for expensive simulations. The same ideas explain wide neural networks (the neural tangent kernel).
- 1. A feature map…
- 2. The kernel trick computes…
- 3. Rings in the plane become linearly separable when you add…
Level 1: Beginner
★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.Feature maps
A feature map turns a linear model in into a nonlinear one in the input: . For example, in 2-D,
gives all quadratic boundaries, and .
Kernels
A kernel is a function . Common choices:
- linear:
- polynomial: , all monomials up to degree p
- RBF (Gaussian): , an infinite-dimensional φ
The polynomial feature space has dimensions: 5151 for d = 100 and p = 2, and about 97 million for p = 5. The kernel costs O(d) either way.
The Gram matrix
For data , the Gram matrix holds everything a kernel method needs.
- 1. (x·z + 1)² for x = (1, 2), z = (3, 4):
- 2. The RBF kernel's feature space is…
- 3. Dimension of all monomials of degree ≤ 2 in 100 variables:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.Kernelizing an algorithm
The perceptron’s weight vector is always a combination of the training points: , with αᵢ the number of mistakes made on point i. So
Training and prediction only use kernel values, so the kernel perceptron is exactly the explicit perceptron in feature space, without ever forming φ. The same rewrite works for ridge regression, SVMs, PCA, k-means and nearest neighbours (all depend only on inner products and distances, since ).
The cost trade-off
Explicit features cost O(mD); kernels cost O(m²) memory and up to O(m³) time. Kernels win when D is huge, and lose when m is huge.
- 1. In the kernel perceptron, αᵢ is…
- 2. ‖φ(x) − φ(z)‖² equals…
- 3. Kernel methods scale badly in…
Level 3: Advanced
★★★★☆ Advanced⏱ 35 minGraduate level, with full derivations and proofs.Why the RBF kernel is an inner product
Factor and expand . Each is a polynomial kernel with explicit features, so the RBF kernel is an inner product of infinitely many scaled monomials. ∎
Bochner’s theorem and random features
A continuous shift-invariant kernel with k(0) = 1 is positive definite exactly when it is the Fourier transform of a probability distribution p(ω). For the RBF kernel, . Then
so with D random rows gives an unbiased approximation with error (Rahimi and Recht, 2007).
- 1. The RBF kernel's spectral distribution is…
- 2. Random Fourier features approximate the kernel with error…
- 3. Bochner's theorem concerns…
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.The kernel trick, measured
Exercise 1 (rings, 200 training points). The quadratic feature map reproduces to machine precision. A linear perceptron scores 49.6% (chance), while the explicit quadratic perceptron and the kernel perceptron both score 99.95%, with identical predictions.
Exercise 2: random Fourier features (d = 5, γ = 0.2, 200 points). The worst-case kernel error falls from 1.15 at D = 10 to 0.39 (D = 100), 0.12 (D = 1000) and 0.039 (D = 10 000), a factor of about √10 per decade, as Monte Carlo predicts. For regression with m = 1000, exact kernel ridge has a test MSE of 0.027, while ridge on 20, 100 and 500 random features scores 0.31, 0.20 and 0.071. Random features trade accuracy for linear-time training.
Kernels in AI, robotics and aerospace
- Gaussian processes for terrain mapping, learning dynamics models and Bayesian optimization of controller gains.
- SVMs with RBF kernels for small-sample classification (fault detection, spectral classification of rocks).
- Random features and Nyström to scale kernel methods to millions of points.
- Neural tangent kernel: infinitely wide networks behave like kernel machines (topic B4.5).
References
- B. Schölkopf, A. J. Smola (2002). Learning with Kernels. MIT Press.
- J. Shawe-Taylor, N. Cristianini (2004). Kernel Methods for Pattern Analysis. Cambridge University Press.
- A. Rahimi, B. Recht (2007). “Random features for large-scale kernel machines.” NeurIPS.
- M. A. Aizerman, E. M. Braverman, L. I. Rozonoer (1964). “Theoretical foundations of the potential function method in pattern recognition learning.” Automation and Remote Control, 25.
- T. Hofmann, B. Schölkopf, A. J. Smola (2008). “Kernel methods in machine learning.” Annals of Statistics, 36(3).