Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Function Spaces and Kernels

A finite sample tells us the value of a curve at only finitely many locations. It cannot determine an arbitrary function everywhere else. Restrictions on the function space and a penalty are what make estimation possible.

Why interpolation is not enough

Suppose a curve f0f_0 interpolates distinct inputs, so that f0(xi)=yif_0(x_i)=y_i. Let

q(x)=∏i=1n(x−xi).q(x)=\prod_{i=1}^{n}(x−x_i).

For any constant cc, the curve fc(x)=f0(x)+cq(x)f_c(x)=f_0(x)+cq(x) gives exactly the same fitted values at the observations. Away from them, changing cc can change the curve arbitrarily. Zero training error therefore tells us very little about prediction.

With distinct inputs, a polynomial of degree at most n−1n−1 can interpolate all nn observations. That is an existence result, not a reason to use such a polynomial as an estimate of a noisy conditional mean.

A norm for functions

A Hilbert space H\mathcal H is an inner product space that is complete: limits of sequences that should converge remain in the space. Its inner product defines a norm through ∥f∥H2=⟨f,f⟩H\lVert f\rVert_{\mathcal H}^2=\langle f,f\rangle_{\mathcal H}.

The evaluation map Lx(f)=f(x)L_x(f)=f(x) is linear. In a reproducing kernel Hilbert space, this map is also bounded: for each xx, there is a finite CxC_x such that

∣f(x)∣≤Cx∥f∥H.|f(x)|\leq C_x\lVert f\rVert_{\mathcal H}.

The Riesz representation theorem then gives a function Kx=K(⋅,x)K_x=K(\cdot,x) satisfying

f(x)=⟨f,Kx⟩H.f(x)=\langle f,K_x\rangle_{\mathcal H}.

This is the reproducing property. It turns evaluation at a point into an inner product, which allows us to use projection geometry in a space of functions.

A reproducing kernel is symmetric and positive semidefinite. For any chosen inputs, the matrix KK with entries Kij=K(xi,xj)K_{ij}=K(x_i,x_j) satisfies a⊤Ka≥0a^\top Ka\geq0. The same letter denotes the kernel and its matrix; the arguments distinguish them.

Why the solution uses only n kernel functions

Let V\mathcal V be the span of K(⋅,x1),…,K(⋅,xn)K(\cdot,x_1),\ldots,K(\cdot,x_n). Any f∈Hf\in\mathcal H decomposes as f=g+hf=g+h, with g∈Vg\in\mathcal V and hh orthogonal to V\mathcal V.

At every observed input,

h(xi)=⟨h,K(⋅,xi)⟩H=0.h(x_i)=\langle h,K(\cdot,x_i)\rangle_{\mathcal H}=0.

Thus ff and gg have the same training residuals. Meanwhile,

∥f∥H2=∥g∥H2+∥h∥H2.\lVert f\rVert_{\mathcal H}^2=\lVert g\rVert_{\mathcal H}^2+\lVert h\rVert_{\mathcal H}^2.

The component hh adds a penalty without improving fit. A minimizer of squared error plus a positive norm penalty must therefore have h=0h=0:

f^(x)=∑i=1naiK(x,xi).\widehat f(x)=\sum_{i=1}^{n}a_iK(x,x_i).

The original search space may be infinite dimensional, but the solution lies in a span generated by the observations.

Minimum norm interpolation

For g=∑iaiK(⋅,xi)g=\sum_i a_iK(\cdot,x_i), its observed values are KaKa and its squared norm is a⊤Kaa^\top Ka. Exact interpolation requires Ka=yKa=y.

The problem is feasible precisely when yy belongs to the range of KK. If KK is invertible, a=K−1ya=K^{−1}y. If it is singular, coefficients need not be unique, but all solutions to Ka=yKa=y represent the same minimum norm function. A coefficient difference vv in the nullspace has v⊤Kv=0v^\top Kv=0 and represents the zero function.

Kernel ridge regression

Instead of requiring interpolation, minimize

∑i{yi−f(xi)}2+λ∥f∥H2,λ>0.\sum_i\{y_i−f(x_i)\}^2+\lambda\lVert f\rVert_{\mathcal H}^2,\qquad\lambda>0.

In kernel coordinates, the objective is ∥y−Ka∥2+λa⊤Ka\lVert y−Ka\rVert^2+\lambda a^\top Ka. A valid coefficient choice, even when KK is singular, is

a=(K+λI)−1y,y^=K(K+λI)−1y.a=(K+\lambda I)^{−1}y,\qquad\widehat y=K(K+\lambda I)^{−1}y.

The function minimizer is unique. With a singular kernel matrix, its coefficient representation can still be nonunique. Do not cancel KK in the normal equations unless it is invertible.

For the linear kernel K(x,z)=x⊤zK(x,z)=x^\top z, this recovers ridge predictions from a linear feature space. Changing the kernel changes which functions are available and what their norm measures.

A kernel based on curvature

The lecture constructs a space on [0,1][0,1] with f(0)=f′(0)=0f(0)=f'(0)=0 and square integrable second derivative. With the appropriate absolute continuity conditions, use

⟨f,g⟩=∫01f′′(u)g′′(u) du.\langle f,g\rangle=\int_0^1 f''(u)g''(u)\,du.

The boundary conditions make this a genuine norm: a linear function satisfying both conditions is zero. A reproducing kernel is

K(x,z)=∫01(x−u)+(z−u)+ du,K(x,z)=\int_0^1(x−u)_+(z−u)_+\,du,

where (v)+=max⁡(v,0)(v)_+=\max(v,0). Taylor’s integral formula gives

f(x)=∫01f′′(u)(x−u)+ du=⟨f,K(⋅,x)⟩.f(x)=\int_0^1 f''(u)(x−u)_+\,du=\langle f,K(\cdot,x)\rangle.

The practical spline model later allows a free intercept and slope. There, curvature is a seminorm because every linear function has zero curvature. Those unpenalized terms must be retained separately; imposing zero boundary values would change the model.