Quant Memo
Advanced

The Representer Theorem

Even when a kernel method searches over an infinite-dimensional space of possible functions, the theorem guarantees the optimal solution is always a finite weighted sum of kernels centered on the training points — which is the reason kernel methods are computable at all.

Prerequisites: Mercer's Condition and Valid Kernels, The Kernel Trick and Kernel Methods

A kernel method like kernel ridge regression is, technically, searching for the best function in an entire infinite-dimensional space of possible functions — every conceivable smooth curve is a candidate. That should be an intractable search: how do you optimize over infinitely many functions with a computer that only has finite memory? The representer theorem is the result that rescues this: it proves the optimal function, whatever infinite space it was theoretically drawn from, always turns out to be expressible using only a finite number of terms — one per training point. The search space collapses from infinite to exactly nn dimensions, where nn is the number of training examples, and that collapse is what makes every kernel method in practical use computationally solvable.

The analogy: mixing paint from only the colors on your palette

Imagine you're told to find the "best" color to paint a wall, searching over every conceivable color in existence — an infinite space. That sounds impossible to search directly. But suppose you're also told: whatever the optimal color turns out to be, it can always be produced as some mixture of exactly the pigments already sitting on your palette, nothing else. Suddenly the infinite search collapses to "how much of each pigment on my palette do I use" — a small, finite, entirely tractable optimization. The representer theorem is exactly this guarantee for kernel methods: whatever function class you're theoretically searching (infinite), the optimal answer is always a mixture of only the kernel functions centered at your nn training points — your "palette."

The statement

For a broad class of problems — minimize a loss on the training data plus a penalty on the function's complexity, measured by its norm fH2\|f\|_{\mathcal H}^2 in the kernel's associated function space (its reproducing kernel Hilbert space) —

f^=argminfHi=1nL(yi,f(xi))+λfH2\hat f = \arg\min_{f \in \mathcal H} \sum_{i=1}^n L(y_i, f(x_i)) + \lambda \|f\|_{\mathcal H}^2

the representer theorem guarantees the minimizer always has the exact finite form

f^(x)=i=1nαik(x,xi)\hat f(x) = \sum_{i=1}^n \alpha_i \, k(x, x_i)

Plain English: no matter how rich or infinite-dimensional the space H\mathcal H theoretically is, the optimal fitted function is always just a weighted sum of "kernel similarity to each training point," with one weight αi\alpha_i per training example — turning an infinite optimization problem into an nn-dimensional one, solvable with ordinary linear algebra.

Worked example 1: kernel ridge regression's closed form

For kernel ridge regression specifically, the representer theorem means the fit reduces to solving one linear system for the nn coefficients α=(α1,,αn)\alpha = (\alpha_1,\dots,\alpha_n):

α=(K+λI)1y\alpha = (K + \lambda I)^{-1} y

where KK is the n×nn\times n Gram matrix from Mercer's condition and yy is the vector of targets. With n=3n=3 training points, K=(210131012)K=\begin{pmatrix}2&1&0\\1&3&1\\0&1&2\end{pmatrix}, λ=1\lambda=1, y=(4,6,2)Ty=(4,6,2)^T: solving (K+I)α=y(K+I)\alpha = y (a 3×33\times3 system, well within reach of ordinary matrix inversion) gives a specific α\alpha vector directly — never an infinite-dimensional object, exactly as the theorem promises, regardless of how complex the underlying kernel's implicit feature space is.

Worked example 2: prediction on a new point

Having solved for α=(1.1,0.8,0.3)\alpha = (1.1, 0.8, -0.3) from three training points x1,x2,x3x_1,x_2,x_3 using an RBF kernel with γ=0.5\gamma=0.5, predicting at a new point xx^* requires only evaluating the kernel between xx^* and each of the three training points and combining: f^(x)=1.1k(x,x1)+0.8k(x,x2)0.3k(x,x3)\hat f(x^*) = 1.1\,k(x^*,x_1) + 0.8\,k(x^*,x_2) - 0.3\,k(x^*,x_3). If k(x,x1)=0.9k(x^*,x_1)=0.9, k(x,x2)=0.2k(x^*,x_2)=0.2, k(x,x3)=0.05k(x^*,x_3)=0.05: f^(x)=1.1(0.9)+0.8(0.2)0.3(0.05)=0.99+0.160.015=1.135\hat f(x^*) = 1.1(0.9)+0.8(0.2)-0.3(0.05) = 0.99+0.16-0.015 = 1.135. Three multiplications and a sum — no matter how exotic the kernel's implicit feature space, prediction always costs exactly nn kernel evaluations, a direct consequence of the theorem's finite-sum form.

Matrix explorer
dashed = before · solid = after
det 1.25trace 2.50λ 1.81, 0.69area scales by 1.25×

Every point in an infinite-dimensional space still has to be reached through finitely many building blocks once you fix a basis — the representer theorem is the statement that, for kernel methods, the training points themselves are always sufficient building blocks, however the underlying space is structured.

The fitted function (solid) is nothing more than a weighted sum of individual kernel "bumps" (dashed), one centered at each training point — exactly the finite sum the representer theorem guarantees.

What this means in practice

The representer theorem is why the kernel trick and finite computation are compatible at all — without it, "optimize over an infinite-dimensional function space" would be a purely theoretical exercise, and kernel SVMs, kernel ridge regression, and Gaussian processes would not exist as practical algorithms. It's also the reason kernel methods scale with the number of training points rather than the number of features: the α\alpha vector has exactly nn entries and the Gram matrix is n×nn\times n, regardless of whether the feature space the kernel implicitly represents is 10-dimensional or infinite-dimensional.

Whatever theoretically infinite space of functions a kernel method searches, the representer theorem guarantees its true optimum is always a finite sum of kernel evaluations against the training points — collapsing an infinite optimization problem into an nn-dimensional one and making every practical kernel algorithm computable.

The representer theorem's finite-sum guarantee is exactly why kernel methods scale poorly with the number of training points, not the number of features — the Gram matrix is n×nn \times n, so training cost grows at least quadratically (often cubically, for the matrix inversion) in nn. This is the opposite scaling behavior from most other model classes, and it's a common surprise: a kernel method that trains instantly on 500 points can become computationally infeasible on 500,000, even if the number of features never changed at all.

Related concepts

Practice in interviews

Further reading

  • Kimeldorf & Wahba, Some Results on Tchebycheffian Spline Functions (1971)
  • Schölkopf, Herbrich & Smola, A Generalized Representer Theorem (2001)
ShareTwitterLinkedIn