The Kernel Trick
The kernel trick lets linear algorithms operate in a high-dimensional feature space using only inner products, never computing the explicit coordinates.
Learning without coordinates
Many learning algorithms depend on the data only through inner products between examples. The kernel trick exploits this: instead of mapping each point x to a high-dimensional feature vector phi(x) and computing
Formally, a function k is a valid (positive semi-definite) kernel if for any finite set of points the Gram matrix K with entries K_ij = k(x_i, x_j) is symmetric positive semi-definite. Mercer's theorem guarantees that such a k corresponds to an inner product in some feature space, possibly infinite-dimensional, as with the Gaussian RBF kernel.
Why it powers support vector machines
A linear support vector machine finds the maximum-margin separating hyperplane. Its dual optimization involves only inner products among training points, so replacing them with k(x_i, x_j) yields a nonlinear classifier in the input space while the optimization stays convex. The same substitution works for ridge regression, principal component analysis, and clustering.
The quantum connection
A quantum feature map defines exactly such an inner product. If |phi(x)> is the quantum state encoding x, then the fidelity |
# Classical kernel SVM skeleton
import numpy as np
def gram(X, kernel):
n = len(X)
K = np.empty((n, n))
for i in range(n):
for j in range(n):
K[i, j] = kernel(X[i], X[j])
return K
# Replace `kernel` with a quantum fidelity estimator to go quantum.
What the trick does not do
- It does not reduce the number of pairwise evaluations: the Gram matrix is quadratic in dataset size.
- It does not guarantee generalization; an over-expressive kernel can overfit and, in the quantum case, produce a nearly diagonal Gram matrix that memorizes rather than learns.
- It does not by itself confer quantum advantage unless the kernel is both useful and classically hard to compute.