5.2 Kernel Ridge Regression

DATA 442/642 · Week 5 · PDF · Slides

Ridge regression in a feature space, without building the features.

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. Kernel ridge regression

Regularized empirical risk in an RKHS is

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

The regularizer Ω(‖f‖2) is typically the squared RKHS norm ‖f‖2.


2. Matrix notation

  • 𝐲: targets.
  • 𝐗: design matrix of inputs.
  • 𝐊: kernel matrix.

The regularizer becomes λθ⊤𝐊θ, where θ holds the coefficients in the RKHS expansion of f.


3. Gradient

The finite-dimensional problem is

minθJ(θ)=(𝐲−𝐊θ)⊤(𝐲−𝐊θ)+λθ⊤𝐊θ.

Differentiate and set to zero:

∂J(θ)∂θ=−2𝐊⊤(𝐲−𝐊θ)+2λ𝐊θ=0.

4. Solving for θ

𝐊⊤𝐊θ−𝐊⊤𝐲+λ𝐊θ=0,

so

(𝐊⊤𝐊+λ𝐈)θ=𝐊⊤𝐲,

and

θ=(𝐊⊤𝐊+λ𝐈)−1𝐊⊤𝐲.

When 𝐊 can be cancelled, the usual kernel-ridge form is

θ=(𝐊+λ𝐈)−1𝐲.

5. Predictions

With that θ,

𝐲^=𝐊θ.

The linear algebra is the same as ridge, but every inner product among features has been replaced by a kernel evaluation. The penalty still controls complexity and overfitting.


6. Practice

  1. What does the kernel trick avoid computing?

  2. Write the usual closed-form θ for kernel ridge in terms of 𝐊, λ, and 𝐲.

  3. Once you have θ, how do you form the vector of training predictions?