The kernel trick evaluates inner products of feature map outputs through without explicitly constructing those vectors. An algorithm expressed entirely through these inner products can therefore operate on nonlinear derived coordinates using only evaluations of a positive-semidefinite kernel on the original inputs. A classifier linear in the derived coordinates can have a nonlinear boundary in the original coordinates.
The polynomial kernel gives a finite, fully visible example: corresponds to . The XOR separation by a product feature below makes the interaction coordinate useful, while dual prediction with a kernel shows how to predict without calculating it explicitly.
An arbitrary score called a similarity need not be a positive-semidefinite kernel. Symmetry alone, even with nonnegative entries, is insufficient: the symmetric matrix
has for , so it cannot be a Gram matrix of real inner products. A positive-semidefinite kernel requires a positive semidefinite matrix for every finite choice of inputs, not just the observed training data.[ref] The existing Moore-Aronszajn theorem connects this requirement to a Reproducing kernel Hilbert space; this example needs only finite linear algebra.
Give the four corners of the square the exclusive or labels: when the input signs differ and when they agree. In the following order,
No affine function has the required strictly positive scores at and strictly negative scores at : both pairs have midpoint zero, so would have to be both positive and negative. This also rules out perfect classification by a single threshold with a consistent tie rule.
Under the polynomial kernel's quadratic feature map, the two classes become two distinct vectors:
The hyperplane separates them. With and , the score and classifier are
All four signed scores equal one. In the input plane the boundary is , the union of the coordinate axes; in the derived coordinates it is a single hyperplane. The feature map identifies opposite corners, which is harmless for these labels because opposite corners belong to the same class. A fixed feature map would not separate labels that disagree at identical mapped vectors.
Figure 1.
XOR labels in the input square and the quadratic feature slice
. The dashed diagonals join equal-label input pairs and share their midpoint, obstructing affine separation. In the feature panel all mapped points have third coordinate one; the two coincident pairs are separated by the horizontal hyperplane at second coordinate zero. Details.
If the weight vector lies in the linear span of the training feature map outputs, write . Then
This 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 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, is
Its 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 . Consequently
For 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.
Figure 1.
Quadratic kernel Gram matrix and a dual prediction for a new input
. Both panels use the same ordered four square corners. The Gram matrix has eigenvalues eight, eight, zero, zero. The new-input column contains four kernel evaluations, whose signed weighted contributions sum to minus one half. Details.
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.
Kernel principal component analysis diagonalizes a centered kernel matrix to perform principal component analysis in an implicit feature space.

Articles by others on the same topic (0)

There are currently no matching articles.