Kernel Linear Regression

Learn to implement kernel linear regression for a single target.

Single target example

It’s possible to reformulate generalized linear regression to incorporate the kernel trick. For example, the loss function L(w)L(\bold w) for generalised linear regression with a single target is as follows:

L(w)=ϕ(X)wy22+λw22L(\bold w)= \|\phi(X) \bold w-\bold y\|_2^2 + \lambda \|\bold w\|_2^2

Note:

wTw=w22\bold w^T\bold w = \|\bold w\|_2^2

Setting the derivative of the loss with respect to w\bold w to 0\bold 0 results in the following:

ϕ(X)T(ϕ(X)wy)+λw=0w=1λϕ(X)T(ϕ(X)wy)w=ϕ(X)Ta\begin{align*} & \phi(X)^T(\phi(X)\bold w-\bold y)+\lambda \bold w = \bold 0 \\ & \bold w = -\frac{1}{\lambda}\phi(X)^T(\phi(X)\bold w-\bold y) \\ & \bold w = \phi(X)^T\bold a \\ \end{align*}

Here, a=1λ(ϕ(X)wy)\bold a=-\frac{1}{\lambda}(\phi(X)\bold w-\bold y).

Reparameterization

We can now parametrize the loss function with parameter vector ...