Explainer

Reproducing Kernel Hilbert Spaces

From vectors to the representer theorem, with the math background taught along the way.

Linear regression with more parameters than data points has many perfect fits. A standard way to choose among them is to pick the fit with the smallest weight norm ∥w∥\norm{w}. That choice needs two ingredients. You need a space of candidate models, and you need a way to measure how big each candidate is.

Now suppose you want to fit a nonlinear function directly, with no weight vector in sight. The candidates are functions, and the space of functions has infinitely many dimensions. What does the size of a function even mean? And how could a computer search an infinite-dimensional space?

A reproducing kernel Hilbert space (RKHS) is a space of functions designed to answer both questions. It comes with a norm that measures how complicated a function is. And the best fit in the entire infinite-dimensional space can be found by solving an n×nn \times n linear system, where nn is the number of data points. It is also the shared language of kernel methods, Gaussian processes, and the neural tangent kernel theory of wide networks.

Notation

SymbolMeaning
X\XThe set of possible inputs. On this page it is usually the real line.
f,g\cf{f}, \cf{g}Functions from X\X to R\R. Blue everywhere.
H\HA Hilbert space whose elements are functions on X\X.
⟨f,g⟩H\ip{f}{g}_{\H}The inner product of two functions in H\H.
∥f∥H\cn{\norm{f}_{\H}}The norm of ff, equal to ⟨f,f⟩H\sqrt{\ip{f}{f}_{\H}}. Magenta everywhere.
LLA linear functional, a linear map from a vector space to R\R.
δx\delta_xThe evaluation functional at xx. It sends ff to the number f(x)f(x).
fS, f⊥f_S,\ f_\perpThe part of ff inside a subspace SS and the part orthogonal to SS.
k(x,x′)\ck{k}(x,x')The kernel, a function of two inputs. Green everywhere.
kx\ck{k_x}The kernel with one slot fixed. It is the function x′↦k(x′,x)x' \mapsto k(x', x), a bump centered at xx.
(xi,yi)(x_i, \cy{y_i})The nn training points. Data is orange everywhere.
KKThe n×nn \times n kernel matrix with entries Kij=k(xi,xj)K_{ij} = k(x_i, x_j).
α\alphaA vector of nn coefficients, one per training point.
φ\varphiA feature map that turns an input xx into a vector of features.
λ\lambdaRegularization strength.
Step 1

Functions are vectors

You already think of a vector in R3\R^3 as a list of three numbers. Another way to say the same thing is that a vector assigns a number to each index 1, 2, 3. That is a function on the set {1,2,3}\{1,2,3\}.

So a function is a vector with one coordinate per input. A function on the real line has one coordinate for every real number, which is why function spaces are infinite-dimensional.

Let X={1,2,3}\X = \{1,2,3\}. Take ff with f(1)=2, f(2)=0, f(3)=−1f(1)=2,\ f(2)=0,\ f(3)=-1 and gg with g(1)=g(2)=g(3)=1g(1)=g(2)=g(3)=1. As vectors these are f=(2,0,−1)f=(2,0,-1) and g=(1,1,1)g=(1,1,1).

Adding functions pointwise is adding vectors. (f+g)(x)=f(x)+g(x)(f+g)(x) = f(x)+g(x) gives (3,1,0)(3,1,0). Scaling works the same way. (2f)(x)=2f(x)(2f)(x) = 2f(x) gives (4,0,−2)(4,0,-2).

Vector space of functions

A set F\mathcal{F} of functions X→R\X \to \R is a vector space if it is closed under pointwise addition and scalar multiplication. For all f,g∈Ff,g \in \mathcal{F} and c∈Rc \in \R, both f+gf+g and cfcf are in F\mathcal{F}.

Takeaway. A function is a vector whose coordinates are indexed by inputs, so everything you know about vectors is worth trying on functions.

Step 2

Inner products and norms

In Rp\R^p the dot product w⊤vw^\top v gives you geometry. It gives lengths through ∥w∥=w⊤w\norm{w} = \sqrt{w^\top w}, and it tells you when two vectors are perpendicular. To do geometry with functions we need the same tool.

An inner product is any rule that takes two vectors and returns a number, as long as it behaves like the dot product. For functions on a finite set, the dot product itself works. For functions on an interval, the sum over coordinates becomes an integral.

On X={1,2,3}\X=\{1,2,3\} with f=(2,0,−1)f=(2,0,-1) and g=(1,1,1)g=(1,1,1) we get ⟨f,g⟩=2+0−1=1\ip{f}{g} = 2+0-1 = 1 and ∥f∥=4+0+1≈2.24\norm{f} = \sqrt{4+0+1} \approx 2.24.

On X=[0,1]\X=[0,1] with f(x)=xf(x)=x and g(x)=1g(x)=1, the integral version gives

⟨f,g⟩L2=∫01x⋅1 dx=12,∥f∥L22=∫01x2 dx=13.\ip{f}{g}_{L^2} = \int_0^1 x \cdot 1 \, dx = \tfrac12, \qquad \norm{f}_{L^2}^2 = \int_0^1 x^2\,dx = \tfrac13 .

This integral inner product is called the L2L^2 inner product. Remember it, because Step 4 shows it is the wrong choice for learning.

Inner product and norm

An inner product on a vector space VV is a map ⟨⋅,⋅⟩:V×V→R\ip{\cdot}{\cdot} : V \times V \to \R with three properties, for all f,g,h∈Vf,g,h \in V and a,b∈Ra,b\in\R.

  1. Symmetry. ⟨f,g⟩=⟨g,f⟩\ip{f}{g} = \ip{g}{f}.
  2. Linearity. ⟨af+bg,h⟩=a⟨f,h⟩+b⟨g,h⟩\ip{af+bg}{h} = a\ip{f}{h} + b\ip{g}{h}.
  3. Positivity. ⟨f,f⟩≥0\ip{f}{f} \ge 0, and ⟨f,f⟩=0\ip{f}{f}=0 only when f=0f=0.

The norm is ∥f∥=⟨f,f⟩\cn{\norm{f}} = \sqrt{\ip{f}{f}}.

Orthogonal

Two elements ff and gg are orthogonal, also called perpendicular, if ⟨f,g⟩=0\ip{f}{g} = 0. An element is orthogonal to a subspace if it is orthogonal to everything in it.

In R2\R^2 the vectors (1,1)(1,1) and (1,−1)(1,-1) are orthogonal because 1−1=01 - 1 = 0. On [0,1][0,1] with the integral inner product, f(x)=1f(x) = 1 and g(x)=x−12g(x) = x - \tfrac12 are orthogonal because ∫01(x−12) dx=0\int_0^1 (x-\tfrac12)\,dx = 0.

The one inequality we will use everywhere

Cauchy–Schwarz inequality

For any ff and gg in an inner product space, the inner product is never bigger than the product of the norms.

∣⟨f,g⟩∣≤∥f∥ ∥g∥|\ip{f}{g}| \le \cn{\norm{f}}\,\cn{\norm{g}}

Here is the proof, since we lean on this three times later. Assume g≠0g \ne 0 and pick any number tt.

0≤∥f−tg∥2a squared norm is never negative=⟨f−tg,f−tg⟩definition of the norm=∥f∥2−2t⟨f,g⟩+t2∥g∥2expand using linearity and symmetry=∥f∥2−⟨f,g⟩2∥g∥2choose t=⟨f,g⟩/∥g∥2\begin{aligned} 0 &\le \norm{f - tg}^2 && \text{a squared norm is never negative}\\ &= \ip{f-tg}{f-tg} && \text{definition of the norm}\\ &= \norm{f}^2 - 2t\ip{f}{g} + t^2\norm{g}^2 && \text{expand using linearity and symmetry}\\ &= \norm{f}^2 - \frac{\ip{f}{g}^2}{\norm{g}^2} && \text{choose } t = \ip{f}{g}/\norm{g}^2 \end{aligned}

Move the fraction to the left side, multiply by ∥g∥2\norm{g}^2, and take square roots. That is the inequality.

Takeaway. An inner product gives a function space lengths and angles, and Cauchy–Schwarz bounds any inner product by the two lengths.

Step 3

Hilbert spaces and projection

In infinite dimensions a new problem appears. A sequence of perfectly nice functions can converge to something that is no longer in your space. It is the same problem the rationals have, where 3, 3.1, 3.14, …3,\ 3.1,\ 3.14,\ \dots are all rational and the limit π\pi is not.

A space with no such holes is called complete. A Hilbert space is an inner product space that is complete. Completeness is what guarantees that minimizers and limits exist, so that when we later ask for the best function, there is one.

A hole in a space

Take continuous functions on [0,1][0,1] with the L2L^2 norm. Let fmf_m be 0 on the left, 1 on the right, with a straight ramp of width 1/m1/m in the middle. Each fmf_m is continuous.

As mm grows the ramps get steeper and the functions get closer to each other in norm. The thing they converge to is a step function, which is not continuous. The space of continuous functions with this norm has a hole exactly there.

Hilbert space

A sequence f1,f2,…f_1, f_2, \dots converges to ff if ∥fm−f∥→0\norm{f_m - f} \to 0 as m→∞m \to \infty. The sequence is Cauchy if ∥fm−fm′∥→0\norm{f_m - f_{m'}} \to 0 as m,m′→∞m, m' \to \infty. A space is complete if every Cauchy sequence converges to an element of the space. A Hilbert space is a complete inner product space.

Rp\R^p with the dot product is a Hilbert space. Every finite-dimensional inner product space is one too.

Orthogonal projection

The second thing we need from Hilbert spaces is the shadow of a vector on a subspace. Given a subspace SS, any vector splits into a part inside SS and a part perpendicular to all of SS.

In R3\R^3 let SS be the floor, spanned by (1,0,0)(1,0,0) and (0,1,0)(0,1,0). The vector f=(3,4,5)f=(3,4,5) splits as fS=(3,4,0)f_S=(3,4,0) plus f⊥=(0,0,5)f_\perp=(0,0,5). The squared lengths add up. 50=25+2550 = 25 + 25.

Orthogonal decomposition

Let SS be a finite-dimensional subspace of an inner product space. Every ff can be written as f=fS+f⊥f = f_S + f_\perp, where fS∈Sf_S \in S and ⟨f⊥,g⟩=0\ip{f_\perp}{g} = 0 for every g∈Sg \in S. The squared norms add.

∥f∥2=∥fS∥2+∥f⊥∥2\norm{f}^2 = \norm{f_S}^2 + \norm{f_\perp}^2

Here is the proof. Finite-dimensional subspaces are the only case we need. Pick perpendicular unit vectors e1,…,eme_1,\dots,e_m that span SS. The Gram–Schmidt procedure from linear algebra produces them. Define fS=∑j⟨f,ej⟩ejf_S = \sum_j \ip{f}{e_j} e_j and f⊥=f−fSf_\perp = f - f_S.

⟨f⊥,ei⟩=⟨f,ei⟩−∑j⟨f,ej⟩⟨ej,ei⟩linearity=⟨f,ei⟩−⟨f,ei⟩=0⟨ej,ei⟩ is 1 if i=j and 0 otherwise\begin{aligned} \ip{f_\perp}{e_i} &= \ip{f}{e_i} - \sum_j \ip{f}{e_j}\ip{e_j}{e_i} && \text{linearity}\\ &= \ip{f}{e_i} - \ip{f}{e_i} = 0 && \ip{e_j}{e_i} \text{ is 1 if } i=j \text{ and 0 otherwise} \end{aligned}

So f⊥f_\perp is perpendicular to every eie_i, and therefore to everything in SS. The lengths then obey Pythagoras.

∥f∥2=⟨fS+f⊥,fS+f⊥⟩=∥fS∥2+2⟨fS,f⊥⟩+∥f⊥∥2expand=∥fS∥2+∥f⊥∥2the cross term is zero\begin{aligned} \norm{f}^2 &= \ip{f_S+f_\perp}{f_S+f_\perp}\\ &= \norm{f_S}^2 + 2\ip{f_S}{f_\perp} + \norm{f_\perp}^2 && \text{expand}\\ &= \norm{f_S}^2 + \norm{f_\perp}^2 && \text{the cross term is zero} \end{aligned}

Takeaway. A Hilbert space is an inner product space with no holes, and in it any vector splits into a piece inside a subspace plus a perpendicular piece whose squared lengths add.

Step 4

Why the obvious norm fails

The L2L^2 space from Step 2 is a Hilbert space, so why not use it? Because learning is about function values at points. We observe f(xi)f(x_i) at training inputs and we want f(x)f(x) at test inputs. A useful norm should control those values. The L2L^2 norm does not.

Pause and predictA function is 1 at x0=0.5x_0 = 0.5 and falls linearly to 0 within a distance ww on each side. As ww shrinks toward zero, what happens to its L2L^2 norm? What happens to its value at x0x_0?

The value at x0x_0 stays exactly 1 while the norm goes to zero. Check it with the slider below. In L2L^2, a function can be almost the zero function and still be far from zero at the one point you care about.

Try this. Shrink the spike width. Watch the norm collapse while the value at x0x_0 does not move.
f(x0)\cf{f}(x_0) = ∥f∥L2=2w/3\cn{\norm{f}_{L^2}} = \sqrt{2w/3} =

The norm in the readout comes from a direct calculation. The spike is two mirror-image ramps, so

∥f∥L22=2∫0w(1−tw)2dt=2⋅w3=2w3.\norm{f}_{L^2}^2 = 2\int_0^w \left(1-\frac{t}{w}\right)^2 dt = 2 \cdot \frac{w}{3} = \frac{2w}{3}.
L2L^2 cannot see single points

It is even worse than the plot suggests. Changing a function at a single point does not change any integral. So the L2L^2 norm cannot see the value f(x0)f(x_0) at all. Making L2L^2 fully rigorous requires treating functions that differ on negligible sets as the same object, which needs measure theory. We will not need that, because the spaces we build next avoid the problem.

Takeaway. In L2L^2, being small in norm tells you nothing about being small at a point, so L2L^2 is the wrong space for learning from point values.

Step 5

The definition of an RKHS

The fix is to demand exactly the property L2L^2 lacks. We want a Hilbert space of functions where a small norm forces small values at every point. That demand is the entire definition of an RKHS.

To state it we need one new term. A linear functional is a machine that eats a vector and returns a single number, and does so linearly.

Linear functional

Let VV be a vector space. A linear functional on VV is a map L:V→RL : V \to \R that respects addition and scaling. For all f,g∈Vf, g \in V and all numbers a,ba, b,

L(af+bg)=a L(f)+b L(g).L(af + bg) = a\,L(f) + b\,L(g) .

In Rp\R^p the map L(w)=a⊤wL(w) = a^\top w for a fixed vector aa is a linear functional. For instance L(w)=2w1−w3L(w) = 2w_1 - w_3 on R3\R^3 sends (1,5,4)(1,5,4) to 2−4=−22 - 4 = -2. The map w↦∥w∥w \mapsto \norm{w} is not one, because doubling ww doubles the norm but negating ww does not negate it.

The functional we care about reads off the value of a function at one fixed input.

Evaluation functional

Let H\H be a vector space of functions on X\X and fix an input x∈Xx \in \X. The evaluation functional at xx is the map δx:H→R\delta_x : \H \to \R defined by

δx(f)=f(x).\delta_x(\cf{f}) = \cf{f}(x) .

It is a linear functional because functions add and scale pointwise. We have δx(af+bg)=(af+bg)(x)=af(x)+bg(x)=a δx(f)+b δx(g)\delta_x(af+bg) = (af+bg)(x) = a f(x) + b g(x) = a\,\delta_x(f) + b\,\delta_x(g).

On X={1,2,3}\X=\{1,2,3\} with the dot product, take f=(2,0,−1)f=(2,0,-1). Evaluation at the third point gives δ3(f)=−1\delta_3(f) = -1. And ∣f(3)∣=1≤∥f∥≈2.24|f(3)| = 1 \le \norm{f} \approx 2.24. A coordinate is never bigger than the length of the whole vector, so here evaluation is controlled by the norm with constant 1.

Bounded linear functional

A linear functional LL on a Hilbert space is bounded if there is a constant CC with ∣L(f)∣≤C ∥f∥|L(f)| \le C\,\norm{f} for every ff.

Reproducing kernel Hilbert space

A reproducing kernel Hilbert space on X\X is a Hilbert space H\H whose elements are functions X→R\X \to \R, such that for every x∈Xx \in \X the evaluation functional δx\delta_x is bounded. For each xx there is a constant CxC_x with

∣f(x)∣≤Cx ∥f∥Hfor all f∈H.|\cf{f}(x)| \le C_x \, \cn{\norm{f}_{\H}} \quad \text{for all } f \in \H .
Norm convergence implies pointwise convergence

In an RKHS, for all f,g∈Hf, g \in \H and every x∈Xx \in \X,

∣f(x)−g(x)∣≤Cx ∥f−g∥H.|f(x) - g(x)| \le C_x\, \norm{f-g}_{\H} .

In particular, if ∥fm−f∥H→0\norm{f_m - f}_{\H} \to 0 then fm(x)→f(x)f_m(x) \to f(x) at every point xx.

The proof is one line. We have ∣f(x)−g(x)∣=∣δx(f−g)∣≤Cx∥f−g∥H|f(x) - g(x)| = |\delta_x(f-g)| \le C_x \norm{f-g}_{\H}, where the equality uses linearity of δx\delta_x and the inequality is boundedness.

Spikes are therefore impossible. A function with f(x0)=1f(x_0)=1 must have norm at least 1/Cx01/C_{x_0}.

Notice that no kernel has appeared yet. The name promises a kernel, and the next step shows that boundedness alone forces one to exist.

Takeaway. An RKHS is a Hilbert space of functions in which the value at each point is controlled by the norm.

Step 6

Where the kernel comes from

In Rp\R^p every linear functional is a dot product with some fixed vector. If LL is linear then L(w)=a⊤wL(w) = a^\top w, where aa collects the values of LL on the basis vectors. The same fact holds in any Hilbert space for bounded functionals. It is called the Riesz representation theorem.

On R3\R^3 let L(w)=2w1−w3L(w) = 2w_1 - w_3. Then L(w)=a⊤wL(w) = a^\top w with a=(2,0,−1)a = (2, 0, -1). The functional is fully described by one vector living in the same space.

Riesz representation theorem

Let LL be a bounded linear functional on a Hilbert space H\H. Then there is exactly one element g∈Hg \in \H such that L(f)=⟨f,g⟩HL(f) = \ip{f}{g}_{\H} for every f∈Hf \in \H.

Here is the proof in finite dimensions. Take perpendicular unit vectors e1,…,epe_1,\dots,e_p spanning the space, so that f=∑j⟨f,ej⟩ejf = \sum_j \ip{f}{e_j}e_j.

L(f)=L(∑j⟨f,ej⟩ ej)expand f in the basis=∑j⟨f,ej⟩ L(ej)L is linear=⟨f, ∑jL(ej) ej⟩inner product is linear, and each L(ej) is just a number\begin{aligned} L(f) &= L\Big(\sum_j \ip{f}{e_j}\, e_j\Big) && \text{expand } f \text{ in the basis}\\ &= \sum_j \ip{f}{e_j}\, L(e_j) && L \text{ is linear}\\ &= \Big\langle f,\ \sum_j L(e_j)\, e_j \Big\rangle && \text{inner product is linear, and each } L(e_j) \text{ is just a number} \end{aligned}

So g=∑jL(ej)ejg = \sum_j L(e_j)e_j works. It is also the only choice. If gg and g′g' both work, then ⟨f,g−g′⟩=0\ip{f}{g-g'} = 0 for every ff. Choosing f=g−g′f = g-g' gives ∥g−g′∥2=0\norm{g-g'}^2 = 0, so g=g′g = g'.

In infinite dimensions the same idea works, and boundedness is exactly what makes the infinite sum converge. I am stating the infinite-dimensional theorem without its full proof. This is also the place where completeness from Step 3 is needed.

Apply Riesz to evaluation

In an RKHS each evaluation functional δx\delta_x is bounded. So the Riesz theorem hands us, for each input xx, one special function in H\H.

Reproducing kernel

Let H\H be an RKHS on X\X. For each x∈Xx \in \X, let kx∈H\ck{k_x} \in \H be the element that the Riesz theorem gives for δx\delta_x. It satisfies the reproducing property

f(x)=⟨f,kx⟩Hfor all f∈H.\cf{f}(x) = \ip{\cf{f}}{\ck{k_x}}_{\H} \quad \text{for all } f \in \H .

The reproducing kernel of H\H is the function of two inputs

k(x,x′)=⟨kx,kx′⟩H.\ck{k}(x, x') = \ip{\ck{k_x}}{\ck{k_{x'}}}_{\H} .

Taking the inner product with kxk_x reproduces the value of ff at xx. The function kxk_x plays the role that the coordinate vector (0,0,1)(0,0,1) plays for reading off the third coordinate.

Properties of the reproducing kernel

Let kk be the reproducing kernel of an RKHS H\H. Then

  1. kk is symmetric, so k(x,x′)=k(x′,x)k(x,x') = k(x',x).
  2. Its slices are the special functions, so kx′=k(⋅,x′)k_{x'} = k(\cdot, x').
  3. kk is positive semidefinite. For any points x1,…,xnx_1,\dots,x_n and numbers c1,…,cnc_1,\dots,c_n we have ∑i,jcicj k(xi,xj)≥0\sum_{i,j} c_i c_j\, k(x_i,x_j) \ge 0.
  4. Every f∈Hf \in \H satisfies ∣f(x)∣≤∥f∥Hk(x,x)|\cf{f}(x)| \le \cn{\norm{f}_{\H}}\sqrt{\ck{k}(x,x)}.

The proof takes the four parts in turn.

It is symmetric. k(x,x′)=k(x′,x)k(x,x') = k(x',x) because inner products are symmetric.

Its slices are the special functions. Apply the reproducing property to the function f=kx′f = k_{x'} at the point xx.

kx′(x)=⟨kx′,kx⟩H=k(x,x′)k_{x'}(x) = \ip{k_{x'}}{k_x}_{\H} = k(x, x')

So kx′k_{x'} is the function you get from kk by fixing the second slot at x′x', which is what k(⋅,x′)k(\cdot, x') means.

It is positive semidefinite. Take any points x1,…,xnx_1,\dots,x_n and any numbers c1,…,cnc_1,\dots,c_n.

∑i,jcicj k(xi,xj)=∑i,jcicj⟨kxi,kxj⟩definition of k=⟨∑icikxi, ∑jcjkxj⟩linearity in both slots=∥∑icikxi∥2 ≥ 0a squared norm\begin{aligned} \sum_{i,j} c_i c_j\, k(x_i,x_j) &= \sum_{i,j} c_i c_j \ip{k_{x_i}}{k_{x_j}} && \text{definition of } k\\ &= \Big\langle \sum_i c_i k_{x_i},\ \sum_j c_j k_{x_j} \Big\rangle && \text{linearity in both slots}\\ &= \Big\lVert \sum_i c_i k_{x_i} \Big\rVert^2 \ \ge\ 0 && \text{a squared norm} \end{aligned}

In matrix language, the kernel matrix KK with Kij=k(xi,xj)K_{ij}=k(x_i,x_j) satisfies c⊤Kc≥0c^\top K c \ge 0 for every cc.

It bounds function values. By the reproducing property and Cauchy–Schwarz,

∣f(x)∣=∣⟨f,kx⟩∣≤∥f∥H ∥kx∥H=∥f∥Hk(x,x).|\cf{f}(x)| = |\ip{f}{k_x}| \le \cn{\norm{f}_{\H}}\,\norm{k_x}_{\H} = \cn{\norm{f}_{\H}}\sqrt{\ck{k}(x,x)} .

This is the best possible constant CxC_x in the definition of an RKHS.

Linear functions

Let H\H be all linear functions on R2\R^2, written fw(x)=w⊤xf_w(x) = w^\top x, with inner product ⟨fw,fv⟩=w⊤v\ip{f_w}{f_v} = w^\top v. Which function kxk_x reproduces evaluation at xx? We need ⟨fw,kx⟩=w⊤x\ip{f_w}{k_x} = w^\top x for all ww, so kx=fxk_x = f_x. The kernel is k(x,x′)=⟨fx,fx′⟩=x⊤x′k(x,x') = \ip{f_x}{f_{x'}} = x^\top x'.

With w=(2,−1)w=(2,-1) and x=(1,3)x=(1,3) we get fw(x)=2−3=−1f_w(x) = 2 - 3 = -1, and ⟨fw,kx⟩=w⊤x=−1\ip{f_w}{k_x} = w^\top x = -1. This is called the linear kernel. Ordinary linear regression already lives in an RKHS.

Takeaway. Bounded evaluation forces the existence of a kernel kk, which is symmetric, positive semidefinite, and reads off function values through f(x)=⟨f,kx⟩f(x) = \langle f, k_x\rangle.

Step 7

Building the space from a kernel

Step 6 went from a space to a kernel. In practice people go the other way. They pick a kernel and let it define the space. This works because any symmetric positive semidefinite function is the kernel of exactly one RKHS.

Kernel

A function k:X×X→Rk : \X\times\X \to \R is a kernel (also called a positive definite kernel) if it is symmetric and for every nn, every choice of points x1,…,xnx_1,\dots,x_n, and every c∈Rnc \in \R^n,

∑i=1n∑j=1ncicj k(xi,xj) ≥ 0.\sum_{i=1}^n\sum_{j=1}^n c_i c_j\, \ck{k}(x_i,x_j) \ \ge\ 0 .
Terminology

The literature says "positive definite kernel" for this condition even though the inequality is not strict.

A kernel and a non-kernel

The Gaussian kernel on the real line is k(x,x′)=exp⁡ ⁣(−(x−x′)2/(2ℓ2))k(x,x') = \exp\!\big(-(x-x')^2/(2\ell^2)\big). The number ℓ\ell is called the lengthscale. For ℓ=1\ell=1 and the points 00 and 11, the kernel matrix is

K=(10.6070.6071),c⊤Kc=c12+c22+1.213 c1c2 ≥0.K = \begin{pmatrix} 1 & 0.607\\ 0.607 & 1\end{pmatrix}, \qquad c^\top K c = c_1^2 + c_2^2 + 1.213\,c_1c_2 \ \ge 0 .

The last inequality holds because the cross term can never outweigh c12+c22c_1^2 + c_2^2.

A non-example is distance. Take k(x,x′)=∣x−x′∣k(x,x') = |x-x'| with the same two points. Then KK has zeros on the diagonal and ones off it. Choosing c=(1,−1)c = (1,-1) gives c⊤Kc=−2c^\top K c = -2. So not every similarity-like function is a kernel.

The construction

Start with the bump functions kx=k(⋅,x)k_x = k(\cdot,x), one for each input xx. Step 6 says these must be in the space. So take all finite weighted sums of bumps.

f=∑i=1mαi k(⋅,xi)\cf{f} = \sum_{i=1}^m \alpha_i\, \ck{k}(\cdot, x_i)

Step 6 also says what the inner product between two bumps must be, namely ⟨kx,kx′⟩=k(x,x′)\ip{k_x}{k_{x'}} = k(x,x'). Extending by linearity leaves no choice for sums. If g=∑jβjk(⋅,zj)g = \sum_j \beta_j k(\cdot, z_j) then

⟨f,g⟩=∑i∑jαiβj k(xi,zj),so∥f∥2=∑i,jαiαj k(xi,xj)=α⊤Kα.\ip{f}{g} = \sum_{i}\sum_{j} \alpha_i \beta_j\, \ck{k}(x_i, z_j), \qquad\text{so}\qquad \cn{\norm{f}^2} = \sum_{i,j}\alpha_i\alpha_j\, k(x_i,x_j) = \alpha^\top K \alpha .

Check that the reproducing property holds with this inner product. Take g=k(⋅,x)g = k(\cdot, x), a single bump with weight 1.

⟨f,k(⋅,x)⟩=∑iαi k(xi,x)=f(x)\ip{f}{k(\cdot,x)} = \sum_i \alpha_i\, k(x_i, x) = f(x)

The last equality is just the definition of ff evaluated at xx. Finally, fill the holes by adding the limits of Cauchy sequences, as in Step 3.

Moore–Aronszajn theorem

For every kernel kk on X\X there is exactly one RKHS of functions on X\X whose reproducing kernel is kk. It is the completion of the space of finite sums ∑iαik(⋅,xi)\sum_i \alpha_i k(\cdot,x_i) under the inner product above.

What the construction skips

The theorem appears in Aronszajn (1950), who credits the idea to E. H. Moore. Three details are skipped here. The inner product does not depend on how ff is written as a sum. It is strictly positive for f≠0f \neq 0. And the limits added during completion are still genuine functions on X\X. All three are proved in the references at the end.

Pause and predictPlace two Gaussian bumps almost on top of each other. Case A gives both weight +1+1. Case B gives them weights +1+1 and −1-1. Both have ∑iαi2=2\sum_i \alpha_i^2 = 2. Which case has the larger RKHS norm?

Case A. The bumps overlap, so k(x1,x2)≈1k(x_1,x_2) \approx 1 and ∥f∥2=α12+α22+2α1α2k(x1,x2)\norm{f}^2 = \alpha_1^2+\alpha_2^2+2\alpha_1\alpha_2 k(x_1,x_2). That is about 44 in case A and about 00 in case B. This makes sense because in case B the two bumps cancel and ff is nearly the zero function. The norm measures the function, not the coefficients. Try both cases below.

Try this. Each handle is one bump. Drag it sideways to move its center and up or down to change its weight αi\alpha_i. Compare the RKHS norm with the plain sum of squared weights.
f=∑iαik(⋅,xi)f = \sum_i \alpha_i k(\cdot,x_i)individual bumps αik(⋅,xi)\alpha_i k(\cdot,x_i)handle at (center, weight)
∥f∥H2=α⊤Kα\cn{\norm{f}_{\H}^2} = \alpha^\top K\alpha = ∑iαi2\sum_i \alpha_i^2 = max⁡x∣f(x)∣\max_x |\cf{f}(x)| =

While you play, check the bound from Step 6. For the Gaussian kernel k(x,x)=1k(x,x)=1, so ∣f(x)∣≤∥f∥H|f(x)| \le \norm{f}_{\H} at every point. The maximum of ∣f∣|f| in the readout never exceeds the square root of the norm readout.

Takeaway. Choosing a kernel chooses the space. Its functions are weighted sums of kernel bumps and their limits, and the squared norm of such a sum is α⊤Kα\alpha^\top K \alpha.

Step 8

The feature map view

There is a second way to see the same space, and it connects straight back to linear regression. A kernel is a dot product between feature vectors. An RKHS is the set of linear models on those features, and the RKHS norm is the weight norm.

Take the polynomial kernel k(x,x′)=(1+xx′)2k(x,x') = (1+xx')^2 on the real line. Expand the square.

(1+xx′)2=1+2xx′+x2x′2=φ(x)⊤φ(x′)withφ(x)=(1, 2 x, x2)(1+xx')^2 = 1 + 2xx' + x^2x'^2 = \varphi(x)^\top\varphi(x') \quad\text{with}\quad \varphi(x) = \big(1,\ \sqrt2\,x,\ x^2\big)

Check with x=1x=1 and x′=2x'=2. The kernel gives (1+2)2=9(1+2)^2 = 9. The features are φ(1)=(1,2,1)\varphi(1) = (1, \sqrt2, 1) and φ(2)=(1,22,4)\varphi(2) = (1, 2\sqrt2, 4), with dot product 1+4+4=91 + 4 + 4 = 9.

Try this. Move xx and x′x'. The kernel value and the feature dot product always agree, even though the kernel never computes the features.
φ(x)\varphi(x) = φ(x′)\varphi(x') = φ(x)⊤φ(x′)\varphi(x)^\top\varphi(x') = k(x,x′)=(1+xx′)2\ck{k}(x,x') = (1+xx')^2 =

Now consider all linear models on these features, fw(x)=w⊤φ(x)=w1+2 w2 x+w3x2f_w(x) = w^\top\varphi(x) = w_1 + \sqrt2\,w_2\,x + w_3x^2. Give them the inner product ⟨fw,fv⟩=w⊤v\ip{f_w}{f_v} = w^\top v. Is this the RKHS of the polynomial kernel? Check the reproducing property. The bump kx′k_{x'} is the model with weights φ(x′)\varphi(x'), since k(x,x′)=φ(x′)⊤φ(x)k(x,x') = \varphi(x')^\top\varphi(x). Then

⟨fw,kx′⟩=w⊤φ(x′)=fw(x′).\ip{f_w}{k_{x'}} = w^\top \varphi(x') = f_w(x') .

It reproduces. By the uniqueness in Step 7, this space of quadratics with the weight-norm is the RKHS. For instance f(x)=x2f(x)=x^2 has weights (0,0,1)(0,0,1) and norm 1, while f(x)=xf(x)=x has weights (0,1/2,0)(0,1/\sqrt2,0) and norm about 0.710.71.

Feature map characterization

Suppose k(x,x′)=⟨φ(x),φ(x′)⟩Wk(x,x') = \ip{\varphi(x)}{\varphi(x')}_{\mathcal{W}} for some map φ\varphi from X\X into a Hilbert space W\mathcal{W} of feature vectors. Then the RKHS of kk is the set of functions fw(x)=⟨w,φ(x)⟩Wf_w(x) = \ip{w}{\varphi(x)}_{\mathcal W}, and

∥f∥H=min⁡{ ∥w∥W : fw=f }.\cn{\norm{f}_{\H}} = \min\{\, \norm{w}_{\mathcal W} \ :\ f_w = f \,\}.
Feature maps are not unique

The minimum matters when several weight vectors give the same function. The RKHS norm is the norm of the smallest one. Every kernel has at least one feature map, namely φ(x)=k(⋅,x)\varphi(x) = k(\cdot, x) with W=H\mathcal W = \H. Feature maps are not unique, but they all give the same RKHS.

The Gaussian kernel needs infinitely many features. For ℓ=1\ell = 1, split the exponent and use the Taylor series of exx′e^{xx'}.

e−(x−x′)2/2=e−x2/2 e−x′2/2 exx′expand the square in the exponent=e−x2/2 e−x′2/2∑j=0∞(xx′)jj!Taylor series of the exponential=∑j=0∞φj(x) φj(x′)withφj(x)=e−x2/2xjj!split each term evenly\begin{aligned} e^{-(x-x')^2/2} &= e^{-x^2/2}\, e^{-x'^2/2}\, e^{xx'} && \text{expand the square in the exponent}\\ &= e^{-x^2/2}\, e^{-x'^2/2} \sum_{j=0}^\infty \frac{(xx')^j}{j!} && \text{Taylor series of the exponential}\\ &= \sum_{j=0}^\infty \varphi_j(x)\,\varphi_j(x') \quad\text{with}\quad \varphi_j(x) = e^{-x^2/2}\frac{x^j}{\sqrt{j!}} && \text{split each term evenly} \end{aligned}

So Gaussian-kernel regression is linear regression on infinitely many features. No computer could store φ(x)\varphi(x), yet k(x,x′)k(x,x') is one line of code. Using kk to get feature dot products without computing features is called the kernel trick.

This is the link to overparameterized linear regression. The minimum-norm interpolator there picks the smallest ∥w∥\norm{w} among weights that fit the data. In an RKHS, picking the smallest ∥f∥H\norm{f}_{\H} is the same act, carried out in a feature space that may be infinite-dimensional.

Takeaway. An RKHS is the set of linear models on some feature map, and the RKHS norm is the smallest weight norm that produces the function.

Step 9

What the norm measures

The RKHS norm is a complexity measure. A function with small norm cannot be large and cannot change quickly. How quickly it may change is set by the kernel.

Smoothness bound

Let H\H be an RKHS with kernel kk. For every f∈Hf \in \H and all inputs x,x′x, x',

∣f(x)−f(x′)∣≤∥f∥H k(x,x)+k(x′,x′)−2k(x,x′).|f(x) - f(x')| \le \cn{\norm{f}_{\H}}\ \sqrt{k(x,x) + k(x',x') - 2k(x,x')} .

The size bound was part 4 of the lemma in Step 6. To prove the bound on change, compare the values at two points using the reproducing property.

∣f(x)−f(x′)∣=∣⟨f,kx⟩−⟨f,kx′⟩∣reproducing property, twice=∣⟨f,kx−kx′⟩∣linearity≤∥f∥H ∥kx−kx′∥HCauchy–Schwarz=∥f∥H k(x,x)+k(x′,x′)−2k(x,x′)expand ∥kx−kx′∥2 with ⟨kx,kx′⟩=k(x,x′)\begin{aligned} |f(x) - f(x')| &= |\ip{f}{k_x} - \ip{f}{k_{x'}}| && \text{reproducing property, twice}\\ &= |\ip{f}{k_x - k_{x'}}| && \text{linearity}\\ &\le \cn{\norm{f}_{\H}}\ \norm{k_x - k_{x'}}_{\H} && \text{Cauchy–Schwarz}\\ &= \cn{\norm{f}_{\H}}\ \sqrt{k(x,x) + k(x',x') - 2k(x,x')} && \text{expand } \norm{k_x-k_{x'}}^2 \text{ with } \ip{k_x}{k_{x'}}=k(x,x') \end{aligned}

Gaussian kernel with ℓ=1\ell = 1 and two points a distance 0.10.1 apart. The square root is 2−2e−0.005≈0.0999\sqrt{2 - 2e^{-0.005}} \approx 0.0999. So any ff in this RKHS satisfies ∣f(x)−f(x′)∣≤0.0999 ∥f∥H|f(x)-f(x')| \le 0.0999\,\norm{f}_{\H}. To jump by 1 over that short distance, a function needs norm at least 10.

An explicit norm

For some kernels the norm has an explicit formula. For the Laplace kernel k(x,x′)=e−∣x−x′∣k(x,x') = e^{-|x-x'|} on the real line it is

∥f∥H2=12∫−∞∞(f(x)2+f′(x)2) dx.\cn{\norm{f}_{\H}^2} = \frac12\int_{-\infty}^{\infty} \big( f(x)^2 + f'(x)^2 \big)\, dx .

That formula penalizes both size and slope. For the Gaussian kernel the penalty involves derivatives of every order, which is why its functions are extremely smooth. The Laplace formula is quoted here as a standard result without a derivation.

Takeaway. A small RKHS norm means the function is small and changes slowly, with the kernel deciding what slowly means.

Step 10

The representer theorem

We can now pose the learning problem. Among all functions in H\H, find the one that fits the data well and has small norm.

min⁡f∈H  ∑i=1n(f(xi)−yi)2 + λ ∥f∥H2\min_{f \in \H}\ \ \sum_{i=1}^n \big(\cf{f}(x_i) - \cy{y_i}\big)^2 \ +\ \lambda\, \cn{\norm{f}_{\H}^2}

The first term is the fit to the data. The second is the complexity penalty, with λ>0\lambda > 0 setting the trade-off.

Pause and predictFor the Gaussian kernel, H\H is infinite-dimensional. How many numbers do you expect it takes to write down the exact minimizer for nn data points?

Exactly nn. The minimizer is a weighted sum of the nn bumps centered at the training inputs. Every other direction in the infinite-dimensional space is useless, for a reason the proof below makes precise.

Representer theorem

Any minimizer of the problem above has the form

f=∑i=1nαi k(⋅,xi)for some α∈Rn.\cf{f} = \sum_{i=1}^n \alpha_i\, \ck{k}(\cdot, x_i) \quad\text{for some } \alpha \in \R^n .
Generality and credit

The same holds if the squared error is replaced by any loss that depends on ff only through f(x1),…,f(xn)f(x_1),\dots,f(x_n), and if λ∥f∥2\lambda\norm{f}^2 is replaced by any strictly increasing function of ∥f∥\norm{f}. The squared-error case goes back to Kimeldorf and Wahba around 1970. The general version is due to Schölkopf, Herbrich and Smola (2001).

Proof

Let SS be the subspace spanned by the nn bumps kx1,…,kxnk_{x_1},\dots,k_{x_n}. It is finite-dimensional, so by Step 3 any f∈Hf\in\H splits as f=fS+f⊥f = f_S + f_\perp with f⊥f_\perp perpendicular to every bump.

The fit term cannot see f⊥f_\perp. At each training point,

f(xi)=⟨f,kxi⟩reproducing property=⟨fS,kxi⟩+⟨f⊥,kxi⟩split f=⟨fS,kxi⟩+0=fS(xi)f⊥ is perpendicular to every bump.\begin{aligned} f(x_i) &= \ip{f}{k_{x_i}} && \text{reproducing property}\\ &= \ip{f_S}{k_{x_i}} + \ip{f_\perp}{k_{x_i}} && \text{split } f\\ &= \ip{f_S}{k_{x_i}} + 0 = f_S(x_i) && f_\perp \text{ is perpendicular to every bump.} \end{aligned}

So ff and fSf_S agree on all the training data and have the same fit term.

The penalty can only grow with f⊥f_\perp. By Pythagoras from Step 3, ∥f∥2=∥fS∥2+∥f⊥∥2\norm{f}^2 = \norm{f_S}^2 + \norm{f_\perp}^2.

Putting these together, if f⊥≠0f_\perp \ne 0 then dropping it keeps the fit identical and strictly lowers the penalty. So a minimizer must have f⊥=0f_\perp = 0. It lies in SS, which means it is a weighted sum of the nn bumps.

Try this. The slider adds tt times a unit-norm function g^\hat g that is perpendicular to all the bumps. Watch the curve change everywhere except at the data. The fit term stays frozen while the penalty grows by exactly t2t^2.
f=fS+t g^f = f_S + t\,\hat gfSf_S alonedata
fit term ∑i(f(xi)−yi)2\sum_i(\cf{f}(x_i)-\cy{y_i})^2 = ∥f∥H2=∥fS∥2+t2\cn{\norm{f}_{\H}^2} = \norm{f_S}^2 + t^2 =
Real computation. g^\hat g is a bump at the wiggle location with its projection onto the five training bumps subtracted, then scaled to unit norm. Gaussian kernel, ℓ=0.7\ell = 0.7.

Takeaway. Anything perpendicular to the training bumps is invisible to the data and costs norm, so the best function is always a sum of nn bumps at the training inputs.

Step 11

Kernel ridge regression

The representer theorem turns a search over functions into a search over nn numbers. All that is left is to plug f=∑jαjk(⋅,xj)f = \sum_j \alpha_j k(\cdot,x_j) into the objective and solve for α\alpha.

Kernel ridge regression

The minimizer of the problem in Step 10 is

f(x)=∑i=1nαi k(x,xi)withα=(K+λI)−1 y.\cf{f}(x) = \sum_{i=1}^n \alpha_i\, \ck{k}(x, x_i) \qquad\text{with}\qquad \alpha = (K + \lambda I)^{-1}\, \cy{y} .

Here is the derivation. Both terms become matrix expressions. The prediction at a training point is f(xi)=∑jαjk(xi,xj)=(Kα)if(x_i) = \sum_j \alpha_j k(x_i,x_j) = (K\alpha)_i. The squared norm is α⊤Kα\alpha^\top K\alpha from Step 7. So the objective is

J(α)=∥Kα−y∥2+λ α⊤Kα.J(\alpha) = \norm{K\alpha - \cy{y}}^2 + \lambda\, \alpha^\top K \alpha .

Set the gradient to zero.

∇J(α)=2K(Kα−y)+2λKαgradient of each term, using K⊤=K=2K[(K+λI)α−y]factor out 2K\begin{aligned} \nabla J(\alpha) &= 2K(K\alpha - y) + 2\lambda K\alpha && \text{gradient of each term, using } K^\top = K\\ &= 2K\big[(K + \lambda I)\alpha - y\big] && \text{factor out } 2K \end{aligned}

The bracket is zero when

α=(K+λI)−1 y,giving the predictionf(x)=∑i=1nαi k(x,xi).\alpha = (K + \lambda I)^{-1}\, \cy{y}, \qquad\text{giving the prediction}\qquad \cf{f}(x) = \sum_{i=1}^n \alpha_i\, \ck{k}(x, x_i).

The matrix K+λIK+\lambda I is always invertible, because KK is positive semidefinite and λ>0\lambda>0. Since JJ is convex, this stationary point is a minimizer.

When KK is not invertible

If two training inputs coincide, KK is singular and other vectors α\alpha also make the gradient zero. They differ from ours by some vv with Kv=0Kv = 0. The function ∑ivik(⋅,xi)\sum_i v_i k(\cdot,x_i) has squared norm v⊤Kv=0v^\top K v = 0, so it is the zero function. Every solution therefore gives the same ff.

Two data points, (x1,y1)=(0,1)(x_1,y_1) = (0,1) and (x2,y2)=(1,0)(x_2,y_2)=(1,0). Gaussian kernel with ℓ=1\ell=1 and λ=0.1\lambda = 0.1.

K+λI=(1.10.6070.6071.1),α=(K+λI)−1(10)≈(1.306−0.720)K + \lambda I = \begin{pmatrix}1.1 & 0.607\\ 0.607 & 1.1\end{pmatrix},\qquad \alpha = (K+\lambda I)^{-1}\begin{pmatrix}1\\0\end{pmatrix} \approx \begin{pmatrix}1.306\\ -0.720\end{pmatrix}

The fitted values are f(0)≈0.869f(0) \approx 0.869 and f(1)≈0.072f(1) \approx 0.072, pulled slightly away from the targets 11 and 00. The squared norm is α⊤Kα≈1.084\alpha^\top K\alpha \approx 1.084.

It contains ordinary ridge regression

The linear kernel gives ridge regression

With the linear kernel k(x,x′)=x⊤x′k(x,x') = x^\top x', the kernel ridge prediction is f(x)=x⊤w∗f(x) = x^\top w^*, where w∗=(X⊤X+λIp)−1X⊤yw^* = (X^\top X + \lambda I_p)^{-1}X^\top y is the ordinary ridge regression solution.

To see this, use the linear kernel. Then K=XX⊤K = XX^\top, where the rows of XX are the training inputs. The prediction at a new xx is

f(x)=∑iαi xi⊤x=x⊤X⊤αdefinition of the linear kernel=x⊤X⊤(XX⊤+λIn)−1yplug in α=x⊤(X⊤X+λIp)−1X⊤yswap identity, explained below\begin{aligned} f(x) &= \sum_i \alpha_i\, x_i^\top x = x^\top X^\top \alpha && \text{definition of the linear kernel}\\ &= x^\top X^\top (XX^\top + \lambda I_n)^{-1} y && \text{plug in } \alpha\\ &= x^\top (X^\top X + \lambda I_p)^{-1} X^\top y && \text{swap identity, explained below} \end{aligned}

The last line is x⊤w∗x^\top w^*. The swap is valid because (X⊤X+λIp)X⊤=X⊤(XX⊤+λIn)(X^\top X + \lambda I_p)X^\top = X^\top(XX^\top + \lambda I_n). Both sides equal X⊤XX⊤+λX⊤X^\top X X^\top + \lambda X^\top. Multiply by the two inverses on either side and you get the swap.

Notice what changed. The familiar ridge formula inverts a p×pp\times p matrix, one row per parameter. The kernel formula inverts an n×nn \times n matrix, one row per data point. When features are infinite, only the second is possible.

The limit of no regularization

As λ→0\lambda \to 0 the fit passes through every training point when KK is invertible, with α=K−1y\alpha = K^{-1}y. Among all functions in H\H that interpolate the data, this one has the smallest norm. It is the function-space twin of the minimum-norm interpolator of overparameterized linear regression.

Pause and predictIn the playground below, you will push λ\lambda toward zero. The curve must then pass through every noisy point. What do you expect to happen to ∥f∥H2\norm{f}_{\H}^2, and does a larger lengthscale make that better or worse?

The norm grows, and a larger lengthscale makes it much worse. Wide bumps are nearly identical to their neighbors, so matching noisy targets needs huge weights of alternating sign that almost cancel. The norm readout can jump by many orders of magnitude. With a short lengthscale each bump handles its own point and the norm stays modest.

Try this. Click empty space to add a point. Drag points to move them. Double-click a point to remove it. Then sweep λ\lambda and ℓ\ell and watch the trade between fit error and the norm. Switch to the Laplace kernel to see how the kernel sets the shape of the fit.
fit ffbumps αik(⋅,xi)\alpha_i k(\cdot,x_i)data
fit error ∑i(f(xi)−yi)2\sum_i(\cf{f}(x_i)-\cy{y_i})^2 = ∥f∥H2=α⊤Kα\cn{\norm{f}_{\H}^2} = \alpha^\top K\alpha = largest ∣αi∣|\alpha_i| =
Real computation. Each redraw solves (K+λI)α=y(K+\lambda I)\alpha = y in your browser.

Takeaway. Kernel ridge regression is α=(K+λI)−1y\alpha = (K+\lambda I)^{-1}y. It is ridge regression in feature space, computed with an n×nn\times n solve no matter how many features there are.

Wrap-up

The whole chain in one place

  1. Functions are vectors, so a set of functions can be a vector space.
  2. An inner product gives that space a norm and Cauchy–Schwarz.
  3. Completeness makes it a Hilbert space, where projections and Pythagoras work.
  4. The L2L^2 norm does not control values at points, so it is a poor fit for learning.
  5. An RKHS is a Hilbert space of functions where each point evaluation is bounded by the norm.
  6. By Riesz, bounded evaluation produces kxk_x with f(x)=⟨f,kx⟩f(x) = \ip{f}{k_x}, and k(x,x′)=⟨kx,kx′⟩k(x,x') = \ip{k_x}{k_{x'}} is symmetric and positive semidefinite.
  7. Conversely every such kk defines one RKHS, made of sums of bumps with ∥f∥2=α⊤Kα\norm{f}^2 = \alpha^\top K\alpha.
  8. Equivalently it is linear models on a feature map, with the RKHS norm equal to the smallest weight norm.
  9. The norm bounds how large ff is and how fast it changes.
  10. Regularized fitting over the whole space always lands on a sum of nn training bumps.
  11. For squared loss the coefficients are α=(K+λI)−1y\alpha = (K+\lambda I)^{-1}y.

Common misconceptions

"The Gaussian RKHS contains every reasonable function." It does not. On an interval it contains no nonzero constant function and no nonzero polynomial (Steinwart, Hush and Scovel 2006, Minh 2010). What is true is that its functions can approximate any continuous function on a bounded closed interval as closely as you like (Steinwart 2001). The approximating functions pay with an exploding norm.

"The RKHS norm is some version of the L2L^2 norm." They are different. A function can have a tiny L2L^2 norm and a huge RKHS norm, as the playground shows when the fit wiggles through noise.

"∥f∥2\norm{f}^2 is the sum of squared coefficients." It is α⊤Kα\alpha^\top K\alpha. Overlapping bumps interact, as in the Step 7 prediction.

"Any similarity function is a kernel." It must be symmetric and positive semidefinite. Distance is a non-example.

"The feature map is part of the definition." Many different feature maps give the same kernel, and they all give the same RKHS. The kernel is the canonical object.

"Kernel methods are a different thing from linear models." They are linear models, in a feature space chosen through kk. All the nonlinearity is in the fixed map φ\varphi. Nothing about φ\varphi is learned from data.

Blind spots worth knowing about

The spectral view (Mercer's theorem). Under mild conditions a kernel can be expanded as k(x,x′)=∑jμj ej(x)ej(x′)k(x,x') = \sum_j \mu_j\, e_j(x) e_j(x') with eigenvalues μj≥0\mu_j \ge 0 and orthonormal eigenfunctions eje_j, the function analog of diagonalizing a symmetric matrix. Then ∥f∥H2=∑jcj2/μj\norm{f}_{\H}^2 = \sum_j c_j^2/\mu_j, where cjc_j is the component of ff along eje_j. Directions with small eigenvalues are expensive, and those are typically the high-frequency ones. This is the tool behind most precise generalization analyses of kernel regression, and it is how the analysis of double descent in linear regression (Hastie et al., listed below) extends beyond plain linear features.

Gaussian processes. A Gaussian process uses the same kk as a covariance function for a random function. Its posterior mean with noise variance λ\lambda is exactly the kernel ridge solution above. A subtle point is that random draws from the process are typically rougher than anything in the RKHS and almost surely lie outside it when the RKHS is infinite-dimensional. Kanagawa et al. (2018) is the reference for these connections.

The neural tangent kernel. Jacot, Gabriel and Hongler (2018) showed that an infinitely wide network, under a particular scaling of the initialization, trains like kernel regression with a fixed kernel determined by the architecture. This is the main reason deep learning theory talks about RKHSs. It is also a limitation. A fixed kernel means the features never change. Other scalings of the network, such as the maximal update parameterization (µP), are designed so that features keep moving at infinite width. That is the regime this theory does not describe.

Beyond RKHS norms. The RKHS norm is an ℓ2\ell_2 norm on a fixed set of features. Networks that learn features behave more like an ℓ1\ell_1-type norm over an infinite pool of possible neurons, which can adapt to structure such as dependence on a few input directions. Bach (2017) contrasts the two function spaces. If you ever see "Barron space" or "variation norm", this is that story.

Random features. Rahimi and Recht (2007) approximate a kernel with a finite number pp of random features and then run plain ridge regression. This gives a bridge between kernel regression (p=∞p = \infty) and the parameter-count axis in double descent plots.

Interpolation without regularization. The λ→0\lambda\to 0 limit, sometimes called ridgeless kernel regression, fits noise exactly and can still generalize in high dimensions. Belkin, Ma and Mandal (2018) argued that this puzzle already appears in kernel methods, not only in deep networks.

Cost. The n×nn \times n solve takes time proportional to n3n^3 and memory proportional to n2n^2. That scaling is the practical reason kernel methods lost ground to networks on large datasets.

Sources and further reading