5.1 Hilbert Spaces

DATA 442/642 · Week 5 · PDF · Slides

Inner-product spaces as the setting for kernels.

These notes walk through the lecture slides. The original deck is unchanged; use (slides) on the course hub if you want that PDF.

The figures follow Deisenroth, Faisal, and Ong, Mathematics for Machine Learning, Theodoridis, and Géron, Hands-On Machine Learning.

1. Central idea

Many datasets live on a nonlinear set. One response is to map the inputs to a new space where the same task becomes linear. Choosing that map is not obvious.

Given pairs (yn,xn) for n=1,…,N, apply ϕ:ℝl→ℝK with K≫l so that the images ϕ(xn) are linearly separable in ℝK.

Points that cannot be separated by a line in the original plane can be separated by a plane after a nonlinear map into 3-space. You have embedded an l-dimensional manifold in a K-dimensional space so the two classes become linearly separable.

Working in that high-dimensional space is expensive: many parameters, computational cost, and a real risk of overfitting.

Nonlinear mapping to a linearly separable space


2. Kernels and RKHS

Instead of writing ϕ and computing inner products of ϕ(xi) and ϕ(xj), define a similarity κ(xi,xj). For a class of similarities called kernels, that function implicitly defines a feature map ϕ.

Let ℍ be a Hilbert space of real-valued functions: an inner product, and completeness in the induced norm. ℍ is a reproducing kernel Hilbert space (RKHS) if there is a kernel κ:𝒳×𝒳→ℝ such that every f∈ℍ and every x∈𝒳 satisfy f(x)=⟨f,κ(·,x)⟩. In this course, think 𝒳=ℝl and ℍ=ℝK.

Each kernel κ has a unique RKHS (Aronszajn, 1950). The canonical feature map is ϕ(x)=κ(·,x), and ℍ is the feature space.

The kernel trick: for any two points,

⟨ϕ(xi),ϕ(xj)⟩=κ(xi,xj).

Inner products in ℍ become a function evaluation in the original low-dimensional space.

Kernel trick in an RKHS

The nonlinear task in the original space is linear in the RKHS. In practice: (a) write the algorithm using only inner products in the original space, then (b) replace those inner products by kernel evaluations.

The matrix 𝐊∈ℝN×N of those pairwise evaluations is the kernel matrix. Every kernel matrix is symmetric and positive semidefinite.

Choose the kernel (and its parameters) by nested cross-validation. The specific formula for κ does not enter the derivation. After you have the predictor, you can swap kernels; each choice is a different nonlinearity.


3. Representer theorem

The representer theorem lets you optimize an empirical loss over a finite sample even when f lives in a very high-dimensional (even infinite-dimensional) RKHS.

Theorem. Let Ω:[0,∞)→ℝ be strictly increasing, and let ℒ:ℝ2→ℝ be any loss. Each minimizer f∈ℍ of

minf∈ℍJ(f)=∑n=1Nℒ(yn,f(xn))+λΩ(‖f‖2)

has the form

f(·)=∑n=1Nθnκ(·,xn),

with θn∈ℝ.

To minimize J you plug in that expansion and optimize only the finite list θ1,…,θN.


4. Practice

  1. What does the kernel trick replace an inner product in ℍ with?

  2. Why is working with an explicit high-dimensional map ϕ expensive?

  3. What does the representer theorem say you may optimize instead of the function f∈ℍ?