Kernel ridge regression uses the kernel k(x,z)=(1+xz)2 on one-dimensional inputs, with penalty λ=1. The training data are (x1,y1)=(0,1) and (x2,y2)=(1,3). Find the dual coefficients α and predict at x=2. Why is the dual form useful?

Supervised learning, Kernel ridge regression
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can derive the kernel ridge solution α=(K+λI)−1y and use it for a prediction without ever writing the feature map.

Key idea

By the representer theorem, f(x)=∑iαik(xi,x), and minimising ∥y−Kα∥2+λα⊤Kα gives α=(K+λI)−1y.

Steps

  1. Write the model as f(x)=∑i=1nαik(xi,x). Here K is the n×n matrix with entries Kij=k(xi,xj). The objective is ∥y−Kα∥2+λα⊤Kα.
  2. Set the gradient to zero: −2K(y−Kα)+2λKα=0. So K((K+λI)α−y)=0, and the solution α=(K+λI)−1y satisfies it.
  3. Build the Gram matrix. k(0,0)=1, k(0,1)=1, k(1,1)=(1+1)2=4. So K=(1114) and K+I=(2115).
  4. The determinant is 2⋅5−1⋅1=9, so (K+I)−1=19(5−1−12).
  5. Multiply by y=(1,3)⊤: α=19(5−3, −1+6)⊤=(2/9, 5/9)⊤.
  6. For x=2 the kernel values are k(0,2)=1 and k(1,2)=(1+2)2=9. So f^(2)=29⋅1+59⋅9=479≈5.22.
  7. The dual form is useful because we only need kernel values, not the feature map. With this kernel the features are (1,2x,x2); with an RBF kernel they are infinite-dimensional. The cost is solving an n×n system, about O(n3).

Common mistakes

How long your answer should be

Half a page; about 5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: Prove that information gain from any split is non-negative, and say when it is exactly zero. Can it be zero for a split that is useful?
Next in Supervised learning: Locally weighted linear regression predicts at a query xq by minimising ∑iwi (yi−θ0−θ1xi)2 with weights wi=exp⁡ ⁣(−(xi−xq)2/(2τ2)). For the data (0,1),(1,3),(2,2), bandwidth τ=1 and query xq=0, compute the prediction. How does it compare with the ordinary least-squares prediction at x=0?