Ali Rahimi 2026-11-05
Ali Rahimi coauthored Random Features for Large-Scale Kernel Machines by Ali Rahimi and Benjamin Recht in 2007. With Benjamin Recht, he proposed explicit randomized maps whose inner products approximate a chosen kernel, enabling familiar fast linear methods in the transformed feature space.[ref]
The Random Fourier feature mechanism samples frequencies from a shift-invariant kernel's spectral representation. This separates the cost of constructing a feature map from the cost of repeatedly evaluating every pairwise kernel value. Accuracy and computation depend on the feature count; randomness does not eliminate approximation error or the need to validate the learned predictor.
Canonical feature space of a positive-semidefinite kernel Created 2026-10-06 Updated 2026-10-14
On the finite formal span of symbols , define and extend bilinearly. For a positive-semidefinite kernel, the null vectors of this positive semidefinite bilinear form form its radical of a bilinear form. Quotienting by that linear subspace gives an inner product space and feature map with . This construction works for degenerate and zero kernels.
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.
Gaussian kernel Created 2026-09-24 Updated 2026-11-05
For , the Gaussian kernel on a Euclidean space isIt is a translation-invariant positive-semidefinite kernel, with . The scale controls the distance over which comparisons remain large: gives . Its feature map requires an infinite-dimensional vector space on the full Euclidean space. Nonlinearity therefore enters through the representation even when a later method is linear in those features.
Kernel method 2026-09-24
A kernel method represents data through a positive-semidefinite kernel, allowing algorithms to use inner products in an implicit feature map.
Kernel trick Created 2026-09-24 Updated 2026-10-14
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 matrixhas 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]
Gaussian Processes for Machine Learning by Carl Edward Rasmussen and Christopher K. I. Williams. Section 4.1, p. 80: Gram matrices, quadratic-form definition of positive semidefiniteness, and nonnegative eigenvalues
The existing Moore-Aronszajn theorem connects this requirement to a Reproducing kernel Hilbert space; this example needs only finite linear algebra. Laplace kernel Created 2026-09-28 Updated 2026-11-05
For , the Laplace kernel on isFor , take independent random variables with Cauchy distribution of scale . Their characteristic functions giveEach sampled frequency has a two-coordinate feature map . Its inner product gives the cosine of the difference, so averaging proves the positive-semidefinite kernel property and yields Random Fourier features. At , the Laplace kernel is the constant-one positive-semidefinite kernel. Negative would violate the two-point Cauchy-Schwarz inequality for positive-semidefinite kernels.
The closure property of positive-semidefinite kernels gives three constructions, each seen directly from the feature maps .
- Nonnegative sums: , for . Its feature map is in the Hilbert space direct sum; expanding its inner product gives .
- Pointwise products: . In the Hilbert tensor product, use : the inner product of two such elementary tensors is the product of their two inner products.
- Input-dependent weighting: for any real-valued function . Its feature map is , so signs of are allowed. Nonnegative scalar multiplication is the special case of constant ; the weighting factor is itself a rank-one positive-semidefinite kernel.
Another useful consequence is pullback: if and is a positive-semidefinite kernel on , then has feature map .
For every , every choice , and every coefficient vector , the required condition isThus for the kernel matrix . For a feature map, this follows fromIn kernel methods, the term positive-definite kernel commonly uses this non-strict inequality. Strict positive definiteness is the stronger requirement that the expression be positive for distinct inputs and every nonzero ; it is not required here.
In this setting a positive-semidefinite kernel is an inner-product similarity: there exist a real Hilbert space and a feature map such thatThe feature map may be infinite-dimensional. Equivalently, is symmetric and every finite kernel matrix is a positive semidefinite matrix. The equivalence follows by forming the canonical feature space of a positive-semidefinite kernel and taking its Hilbert space completion.
Reciprocation reverses the order of positive numbers, soThis is the pullback of the positive-semidefinite kernel from part (i) by . Explicitly, the feature map into the same L2 space isHence is a positive-semidefinite kernel, with for every allowed input.
Take the real L2 space and the feature mapEach indicator function belongs to because its squared L2 norm is . Their inner product is the length of the overlapping intervals:This realizes as a positive-semidefinite kernel; it is also the Brownian covariance kernel.
Evaluating the negative functional gradient at yieldsThus the evaluation vector followsThis is exactly the limiting prediction dynamics in part (ii). If , subtracting the two systems gives with zero initial value, so for every .
An infinitely wide neural network in this regime follows the same training-prediction dynamics as kernel regression with its neural tangent kernel and matching initial predictions. For this squared-error loss function, the relevant algorithm is gradient flow in the Reproducing kernel Hilbert space. Matching predictions at arbitrary additional inputs also requires the corresponding cross-input neural tangent kernel to freeze and the initial predictions there to match. A finite-width neural network can change its feature map during training, so the equivalence depends on the assumptions rather than holding for every architecture and parameterization.
Expanding the squared Euclidean norm givesIn lifted coordinates , this is the closed half-spaceEvery labelling of the original points obtainable by a Euclidean ball is therefore obtainable on their lifted images by an affine linear classifier. The feature map is injective, since it preserves the first coordinates; distinct original points remain distinct. If the original points are shattered, every labelling of the lifted points is realized, as required.
Here “linear separator” means a separator with an intercept, namely an affine hyperplane. If a convention demands strict separation on the finite sample, increase the constant term of the positive score by a sufficiently small positive amount. Positive points then have strictly positive score, and the finitely many negative scores remain strictly negative. A homogeneous separator can alternatively be obtained after adjoining one more constant coordinate; this distinction matters for dimension counts.
A real positive-semidefinite kernel on an input set is a function for which there is an inner product space and a feature map satisfyingEquivalently, is symmetric and every finite Gram matrix is positive semidefinite: for all real coefficients . An infinite-dimensional Hilbert space is allowed.
Replace every inner product in part (b) by and solveThis is precisely the Lagrangian dual problem obtained by replacing each original input by in the primal problem. The weight vector it determines isand the intercept follows from the same Karush-Kuhn-Tucker conditions. For example, if ,Thus training needs only the finite Gram matrix, even if the feature map has infinitely many coordinates. This is the kernel trick. The result is an affine linear classifier in the feature space; its boundary in the original input space can be nonlinear. The squared-slack diagonal term and the equality constraint remain unchanged.
An embedding is determined by its chosen increasing sequence of positions. Accordingly, the all-subsequence embedding kernel counts pairs of embeddings, one in and one in , that spell the same subsequence. The two embeddings are distinguished even when they spell the same word as another pair. The empty word contributes exactly one pair.
Let , , and define for prefixes. When either prefix is empty, only the empty word has an embedding in both, soTo derive a dynamic programming recurrence, count pairs that do not use position of or do not use position of . Inclusion-exclusion givesThe remaining pairs use both final positions. These positions must be the final letters of the common word, so they contribute nothing if . If , deleting those two final positions is a bijection to arbitrary embedding pairs on the two shorter prefixes, including their empty pair. Their contribution is therefore . HenceEquivalently, when the final symbols agree the recurrence simplifies to ; when they differ, subtract the diagonal term. Fill the table in increasing prefix order and return . The boundary values and the disjoint counting argument prove correctness by induction on .
A one-row implementation of this dynamic programming uses the saved old diagonal entry:The assignment to
F[0..p] := 1
for i := 1 to n:
diagonal := 1
for j := 1 to p:
above := F[j]
if x[i] = y[j]:
F[j] := above + F[j-1]
else:
F[j] := above + F[j-1] - diagonal
diagonal := above
return F[p]diagonal retains the value from the previous row before F[j] was overwritten. Swapping and if necessary minimizes the row length. Thus the time complexity is arithmetic operations and the extra space complexity is integer cells. Empty inputs return one immediately.These counts include multiplicity: for , the empty word contributes , the word contributes , and contributes , giving , not three. More generally, each result is at most , since it counts some pairs of position subsets. Exact integers therefore require bits; the stated quadratic bound is an arithmetic-operation bound, with a conservative bound for elementary bit arithmetic.
The proposed positive-semidefinite kernel is valid: for each finite string only finitely many coordinates are nonzero, so is a well-defined feature map into the inner product space of finitely supported coordinate families, and its inner product is exactly .
Past exam of the mathematics course of the University of Cambridge 2016 iii Paper 205 2 Solution Created 2026-10-03 Updated 2026-10-14
Use the normalizationThis is ridge regression; the penalty is the squared Euclidean norm. The centering removes the need for an intercept. Differentiating gives the normal equationFor every nonzero , . The coefficient matrix is therefore a positive-definite matrix, even if the design matrix has deficient matrix rank. The objective is a strictly convex function, so the unique minimizer is the closed-form ridge regression estimator, with fitted values
For the primal-dual identity for ridge regression, put and observeBoth parenthesized matrices are positive-definite matrices. Multiplying by their inverses givesThus the same fitted vector has the dual expressionNo inverse of or alone was needed. This is also the kernel-ridge hat matrix for the linear kernel.
Here a positive-definite kernel means a symmetric real-valued function whose every finite kernel matrix is positive semidefinite: for all , and ,This is the usual positive-semidefinite kernel convention; strict positivity for distinct points is not required. In particular . Write , and . Positivity of the two-point kernel matrix impliesIf , substitute to obtain . If , the affine expression can be nonnegative for every only if . Both cases give the Cauchy-Schwarz inequality for positive-semidefinite kernels:The zero-diagonal case is essential when the positive-definite kernel is not strictly positive.
To construct a feature map, let be the real vector space of finite formal linear combinations of symbols , one for each . Define a symmetric bilinear form byThe positive-definite kernel property makes this a positive semidefinite bilinear form. It need not yet be an inner product: distinct formal vectors can have zero squared length. The same quadratic-polynomial argument, now applied to , provesTherefore implies for every . The setis the radical of a bilinear form, hence a linear subspace. SetThe quotient vector space has a well-defined inner product: changing representatives by elements of changes no pairing, and a zero-length class is exactly the zero class. It is therefore an inner product space.
Define . By construction,Every positive-definite kernel thus has a feature representation, including degenerate kernels and the zero kernel. This is its canonical feature space of a positive-semidefinite kernel. The construction already gives the requested inner product space.
Past exam of the mathematics course of the University of Cambridge 2018 iii Paper 218 2 a Solution Created 2026-10-03 Updated 2026-10-05
In the terminology used for positive-definite kernels, positive definiteness means positive semidefiniteness of every finite kernel matrix: is symmetric and, for every , points and real ,The linear kernel is symmetric, andThus it is a positive-semidefinite kernel, with the identity as its feature map. It need not be strictly positive definite: a zero vector or linearly dependent points can make this quadratic form zero for nonzero . This distinction is essential when interpreting the terminology.
Past exam of the mathematics course of the University of Cambridge 2019 iii Paper 205 3 1 Solution Created 2026-10-03 Updated 2026-10-14
A positive-semidefinite kernel on is a symmetric function such that, for every and ,If for a feature map into an inner product space, thenThus every feature-map inner product is a kernel. If , then each finite quadratic form for is the corresponding nonnegative linear combination, so nonnegative linear combinations of kernels are kernels.
