Computational tradeoffs of the kernel trick 2026-10-14
For input coordinates, the homogeneous quadratic polynomial kernel has a weighted quadratic feature map with distinct monomials. Computing an inner product of already stored mapped vectors costs arithmetic operations, whereas costs using the input vectors. Here denotes big O notation. Higher fixed degrees can make the dimension gap much larger.
Sample count still matters. With training examples, materializing a dense kernel matrix stores numbers and requires distinct evaluations using symmetry. A dense direct solve for kernel ridge regression typically takes operations after constructing the kernel matrix, while a dual prediction with nonzero coefficients uses kernel evaluations. Explicit finite feature maps can be preferable when is small relative to , and a stored primal weight vector can make prediction depend on rather than on . The kernel trick by Ryan Giordano (sections Ridge regression and The polynomial kernel) explains the change from feature-coordinate equations to training-example equations; neither representation is universally faster.
The kernel trick saves explicit feature construction when the positive-semidefinite kernel is economical to evaluate; it does not remove the cost of optimization, choose a useful positive-semidefinite kernel, or establish generalization. Random Fourier features illustrate a different tradeoff: replacing the exact Gaussian kernel with a finite approximate feature map can reduce dependence on the sample count while introducing approximation error.
Dual prediction with a kernel 2026-10-14
If the weight vector lies in the linear span of the training feature map outputs, write . ThenThis is a dual representation: coefficients weight training examples rather than feature coordinates. They need not be positive, and need not be unique when the kernel matrix is singular. Some kernel methods instead write with under their own optimization constraints.[ref]
The kernel trick by Ryan Giordano. Kernelizing classification with support vector machines: displayed prediction as a sum of label-weighted kernel evaluations
The formula is an algebraic conversion for a weight vector in this linear span, not a claim about every possible weight vector. The representer theorem gives a broader reason this form appears in regularized kernel methods.For the XOR separation by a product feature, let have rows . The Gram matrix of those rows, equivalently the kernel matrix, isIts eigenvalues are , so it is a positive semidefinite matrix of rank two, not an invertible matrix. More generally, for any real coefficient vector and any finite set of inputs,This proves the positive-semidefinite kernel condition for the displayed polynomial kernel on all of , rather than checking only this square.
Here , so the explicit choice gives and . ConsequentlyFor the new input , the four polynomial kernel evaluations are . Their weighted sum is , and the sign function predicts . No explicit feature map is needed for this calculation. These coefficients were constructed to reproduce the chosen separator; no fitting algorithm or generalization guarantee is being asserted.
