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.
Kernel support vector machine Created 2026-10-06 Updated 2026-10-14
A kernel support vector machine trains a support vector machine using a positive-definite kernel instead of explicit feature coordinates. The kernel trick evaluates all required feature inner products through the training Gram matrix; prediction is . Nonzero dual coefficients identify support vectors. An unpenalized intercept supplies the dual equality . The Reproducing kernel Hilbert space construction explains why a positive-semidefinite kernel defines valid feature geometry.
Past exam of the mathematics course of the University of Cambridge 2014 iii Paper 65 5 Solution Created 2026-10-03 Updated 2026-10-14
A kernel support vector machine constructs a large-margin classifier in a feature Hilbert space. Given training points and labels , choose a feature map and an affine score . Prediction is the sign of the score. Normalizing the functional margin to one makes the closest separating geometric margin , and the full margin between the two supporting hyperplanes is . Maximizing that margin therefore minimizes .
For separable data, the hard-margin support vector machine primal isNoisy or nonseparable data use slack variables and the soft-margin support vector machine:Eliminating gives the equivalent hinge loss objective . The parameter balances margin size against violations; it is not a hard bound on their number. The bias is unpenalized here, which determines the equality constraint in the dual.
Attach multipliers to and to . The Lagrangian isStationarity gives , and . Eliminating yieldswhere is a positive-definite kernel, meaning positive semidefinite Gram matrices. The hard-margin dual is the same objective with only , without the upper bound. Soft-margin strict feasibility follows by taking and all , so strong duality and the Karush-Kuhn-Tucker conditions apply. For separable hard-margin data a separator can be rescaled to give strict margins, supplying the analogous qualification. Although the feature space may be infinite dimensional, projecting onto the finite span of the training feature vectors preserves scores and cannot increase its norm, so this optimization reduces to a finite span.
The complementary slackness relations arePoints with are support vectors. If , then and ; such a point gives . A point with can lie inside the margin or be misclassified, while contributes no term to . If no coefficient lies strictly between the bounds, an admissible bias must be obtained from the KKT inequalities, rather than dividing by a nonexistent margin vector. Bias and dual coefficients can be nonunique even when the optimal feature-space weight is unique.
The kernel trick operates both during training and prediction. The dual optimization uses only the Gram matrix , so the feature vectors need not be formed. Prediction likewise usesA nonlinear kernel therefore makes a linear separator in feature space represent a nonlinear boundary in input space. For example, on the degree-two polynomial kernel corresponds to . Gaussian kernels yield infinite-dimensional feature spaces. An arbitrary similarity is not automatically a valid kernel: for every finite collection and real coefficients , one needs . This makes the dual quadratic form positive semidefinite and the maximization concave.
Mercer's theorem gives a spectral realization under its additional analytic hypotheses. For a continuous symmetric positive-semidefinite kernel on a compact domain with a finite full-support measure, the integral operator is compact, self-adjoint and positive. The Mercer expansion iswith the standard uniform convergence conclusions under these hypotheses. Since , the nonlinear feature mapis well defined. This explains the connection of Mercer kernels to Hilbert space features, rather than treating the kernel trick as a purely formal substitution.
The finite-Gram positivity condition is more general than this compact-domain spectral theorem. Every such kernel generates a Reproducing kernel Hilbert space: on finite sums of kernel sections definequotient out zero-norm elements, and complete. The resulting space satisfies the reproducing property . Its canonical feature map is , whose inner product is exactly . A feature map need not be injective; calling it an embedding does not by itself prove distinct inputs remain distinct. The kernel support vector machine uses this geometry together with convex duality to fit and evaluate a maximum-margin classifier while accessing the geometry only through kernel evaluations.
Past exam of the mathematics course of the University of Cambridge 2022 iii Paper 218 2 d Solution 2026-09-28
The kernel trick replaces inner products by evaluations of a positive-semidefinite kernel without explicitly constructing the feature vectors. In the corresponding reproducing-kernel Hilbert space, the hard-margin problem isEquivalently, its dual isThere is no upper bound because this is the hard-margin, rather than soft-margin, problem.
Kernel principal component analysis diagonalizes the centered by kernel matrix instead of an explicit covariance operator in a possibly infinite-dimensional feature space. A new point has coordinateso the leading coordinates require only evaluations of the positive-semidefinite kernel.
Running the K-nearest neighbors algorithm in a truncated collection of these coordinates can remove low-variance noise, reduce effective dimension, and allow a nonlinear boundary in the original covariates. This is the kernel trick: every feature-space inner product needed for fitting and projection is replaced by without constructing explicitly.
Past exam of the mathematics course of the University of Cambridge 2026 iii Paper 218 4 f Solution Created 2026-09-24 Updated 2026-09-25
The feature space may be extremely high-dimensional or infinite-dimensional, and may be known only implicitly. Instead, compute the leading eigenvector of the kernel matrix , normalize it by , and use the kernel trick:This requires only kernel evaluations.
Polynomial kernel 2026-10-14
For , a polynomial kernel is the positive-semidefinite kernel , where is a positive integer and . The case uses monomials of total degree ; also includes lower degrees. The feature map weights matter: listing each distinct monomial once with coefficient one generally gives a different inner product.[ref]
Gaussian Processes for Machine Learning by Carl Edward Rasmussen and Christopher K. I. Williams. Section 4.2.2, pp. 89–90, equations (4.23)–(4.24): polynomial kernels and weighted monomial features
For the homogeneous quadratic case in two dimensions, take the scaled quadratic feature mapThe inner product identity is explicit:The factor accounts for the two equal cross terms in the square. Thus an inner product of three derived coordinates can be obtained from an inner product of the two input coordinates followed by squaring. The kernel trick uses this equality inside an algorithm; the feature map explains which nonlinear functions the algorithm can represent.