Skip to content
Lambdian

Kernel trick

Using a similarity function to work in a huge feature space without ever computing the features.

Algorithms that only use dot products between examples, such as the SVM dual, can replace xi⊤xj\mathbf{x}_i^\top\mathbf{x}_j with a kernel K(xi,xj)K(\mathbf{x}_i, \mathbf{x}_j) that equals a dot product in some richer space. The RBF kernel

K(x,z)=exp⁡(−γ∥x−z∥2)K(\mathbf{x},\mathbf{z}) = \exp(-\gamma\lVert\mathbf{x}-\mathbf{z}\rVert^2)

corresponds to an infinite-dimensional space but costs one exponential to compute. This turns linear methods into flexible non-linear ones; the cost is an n×nn\times n kernel matrix.

See it in action