Tutorials › Statistical Learning (Graduate) › Canonical Feature Maps and Kernel Sections

RKHS and Representer Theory · Tutorial 694 of 989

Canonical Feature Maps and Kernel Sections

Learn to interpret kernel sections as feature vectors, calculate their inner products, and understand why different feature representations encode the same geometry.

Intermediate 11 min read

What You'll Learn

  • Define the canonical feature map using kernel sections in the associated RKHS
  • Derive the identity between feature inner products and kernel values
  • Compute norms and distances between canonical feature vectors
  • Verify feature identities in finite and infinite-dimensional examples
  • Relate any other feature representation to the canonical map by an isometry

From Kernel Sections to Feature Vectors

A positive definite kernel can be viewed as a rule for comparing inputs. Its value \(k(x,y)\) is not merely a similarity score: in the reproducing kernel Hilbert space (RKHS) associated with \(k\), it is the inner product of two particular functions. Those functions are the kernel sections, and treating them as feature vectors gives a canonical way to represent each input.

This viewpoint is useful because it turns kernel calculations into ordinary Hilbert-space geometry without requiring coordinates for the RKHS. The map is canonical once the kernel and its RKHS are fixed, although other feature representations of the same kernel may use different spaces or coordinates.

Definition: Let \(X\) be a set, let \(k:X\times X\to\mathbb{R}\) be a positive definite kernel, and let \(\mathcal{H}_k\) be its associated real RKHS. For \(x\in X\), the kernel section at \(x\) is the function \(k_x=k(\,\cdot\,,x)\) in \(\mathcal{H}_k\). The canonical feature map is $$ \Phi:X\to\mathcal{H}_k,\qquad \Phi(x)=k_x. $$

The defining reproducing property of \(\mathcal{H}_k\) states that \(f(x)=\langle f,k_x\rangle_{\mathcal{H}_k}\) for every \(f\in\mathcal{H}_k\) and \(x\in X\). In particular, each section is a function on the input set: its value at \(z\) is \(k_x(z)=k(z,x)\). It is not just the number \(k(x,x)\).

The Feature-Inner-Product Identity

The fundamental identity follows directly from reproduction. Apply the reproducing property to the function \(k_y\), evaluated at \(x\). Symmetry of a real positive definite kernel then gives the result.

Theorem: For all \(x,y\in X\), the canonical feature map satisfies $$ \langle \Phi(x),\Phi(y)\rangle_{\mathcal{H}_k}=k(x,y). $$

Proof. Since \(k_y\in\mathcal{H}_k\), the reproducing property gives

$$ \langle k_y,k_x\rangle_{\mathcal{H}_k}=k_y(x)=k(x,y). $$

The real Hilbert-space inner product is symmetric, so \(\langle k_y,k_x\rangle_{\mathcal{H}_k}=\langle k_x,k_y\rangle_{\mathcal{H}_k}\). Using \(\Phi(x)=k_x\) and \(\Phi(y)=k_y\) proves the identity. \(\square\)

Thus a kernel value is exactly an inner product between canonical feature vectors. This also gives immediate formulas for their lengths and separation. These formulas follow by expanding the squared norm and applying the identity just proved.

$$ \|\Phi(x)\|_{\mathcal{H}_k}^2=k(x,x),\qquad \|\Phi(x)-\Phi(y)\|_{\mathcal{H}_k}^2 =k(x,x)+k(y,y)-2k(x,y). $$

Worked Example: Sections on a Three-Point Input Set

Let \(X=\{a,b,c\}\), and define vectors \(u(a)=(1,0)\), \(u(b)=(0,1)\), and \(u(c)=(1,1)\) in \(\mathbb{R}^2\). Set \(k(x,y)=u(x)^\mathsf{T}u(y)\). This is positive definite: for any inputs \(x_1,\ldots,x_m\) and real coefficients \(q_1,\ldots,q_m\), $$ \sum_{i=1}^m\sum_{j=1}^m q_iq_jk(x_i,x_j) =\left\|\sum_{i=1}^m q_i u(x_i)\right\|_{\mathbb{R}^2}^2\geq 0. $$

The kernel values are \(k(a,a)=1\), \(k(b,b)=1\), \(k(c,c)=2\), \(k(a,b)=0\), and \(k(a,c)=k(b,c)=1\). By the feature-inner-product identity, the canonical sections have these same inner products. Therefore \(\Phi(a)\) and \(\Phi(b)\) are orthogonal unit vectors, while \(\|\Phi(c)\|^2=2\).

The relation between the sections can be checked as functions. Their values, listed in the order \(a,b,c\), are $$ k_a=(1,0,1),\qquad k_b=(0,1,1),\qquad k_c=(1,1,2). $$ Hence \(k_c=k_a+k_b\), or equivalently \(\Phi(c)=\Phi(a)+\Phi(b)\). The squared norm on the right is \(1+1+2(0)=2\), agreeing with \(k(c,c)\).

Linear Combinations of Canonical Features

The identity applies not only to single feature vectors but also to every finite linear combination of them. The resulting calculation is often the practical reason to use the canonical map: inner products and norms of combinations can be computed entirely from kernel values.

Derived identity: For inputs \(x_1,\ldots,x_m\), \(y_1,\ldots,y_r\) and real coefficients \(\alpha_1,\ldots,\alpha_m\), \(\beta_1,\ldots,\beta_r\), $$ \left\langle\sum_{i=1}^m\alpha_i\Phi(x_i), \sum_{j=1}^r\beta_j\Phi(y_j)\right\rangle_{\mathcal{H}_k} =\sum_{i=1}^m\sum_{j=1}^r\alpha_i\beta_j k(x_i,y_j). $$

To derive this, expand the inner product using bilinearity:

$$ \left\langle\sum_i\alpha_i\Phi(x_i),\sum_j\beta_j\Phi(y_j)\right\rangle =\sum_i\sum_j\alpha_i\beta_j\langle\Phi(x_i),\Phi(y_j)\rangle =\sum_i\sum_j\alpha_i\beta_jk(x_i,y_j). $$

In particular, taking the two combinations to be the same gives $$ \left\|\sum_{i=1}^m\alpha_i\Phi(x_i)\right\|_{\mathcal{H}_k}^2 =\sum_{i=1}^m\sum_{j=1}^m\alpha_i\alpha_j k(x_i,x_j). $$

Worked Example: A Linear Combination for \(k(x,y)=1+xy\)

On \(X=\mathbb{R}\), define \(k(x,y)=1+xy\). This is positive definite because \(k(x,y)=(1,x)^\mathsf{T}(1,y)\), so every finite quadratic form in kernel values is a squared Euclidean norm. Consider the combination \(2\Phi(2)-\Phi(-1)\).

First calculate the required kernel values: \(k(2,2)=1+4=5\), \(k(-1,-1)=1+1=2\), and \(k(2,-1)=1-2=-1\). The norm identity gives

$$ \begin{aligned} \|2\Phi(2)-\Phi(-1)\|_{\mathcal{H}_k}^2 &=4k(2,2)+k(-1,-1)-4k(2,-1)\\ &=4(5)+2-4(-1)\\ &=26. \end{aligned} $$

Thus the norm is \(\sqrt{26}\). The negative cross-kernel value is not a problem: positive definiteness requires nonnegative quadratic forms, not nonnegative values of \(k(x,y)\) for every pair.

Other Feature Maps and the Canonical Representation

A feature map need not take values in \(\mathcal{H}_k\). More generally, a map \(\psi:X\to G\), where \(G\) is a real Hilbert space, is a feature representation of \(k\) if \(k(x,y)=\langle\psi(x),\psi(y)\rangle_G\) for every pair \(x,y\). The coordinates and even the ambient space can differ from those of the canonical map.

Theorem: Suppose \(k\) is a positive definite kernel with RKHS \(\mathcal{H}_k\), and \(\psi:X\to G\) is a feature representation of \(k\). There is a unique linear isometry from the closed linear span of \(\{\Phi(x):x\in X\}\) in \(\mathcal{H}_k\) onto the closed linear span of \(\{\psi(x):x\in X\}\) in \(G\), mapping each \(\Phi(x)\) to \(\psi(x)\).

Proof. On finite linear combinations, define \(U(\sum_i\alpha_i\Phi(x_i))=\sum_i\alpha_i\psi(x_i)\). The formula for squared norms of combinations shows that both sides have the same squared norm:

$$ \left\|\sum_i\alpha_i\Phi(x_i)\right\|_{\mathcal{H}_k}^2 =\sum_{i,j}\alpha_i\alpha_jk(x_i,x_j) =\left\|\sum_i\alpha_i\psi(x_i)\right\|_G^2. $$

This equality proves that \(U\) is well-defined. Indeed, if one representation of a vector has sum zero in \(\mathcal{H}_k\), its squared norm is zero, so the corresponding sum in \(G\) also has squared norm zero and is the zero vector. Applying the same argument to differences of representations shows that the assigned value does not depend on the chosen representation. The norm equality also shows that \(U\) is linear and preserves norms on the span.

Because \(U\) preserves distances, it extends uniquely by limits to an isometry on the closed span of the canonical features: a Cauchy sequence of finite combinations is sent to a Cauchy sequence in the complete space \(G\), and equivalent sequences have the same limit. The image of this extension is closed, since an isometric image of a complete space is complete and hence closed in \(G\). It contains every \(\psi(x)=U\Phi(x)\), so it contains their closed linear span. It is also contained in that closed span by construction; therefore it equals the closed span of the \(\psi(x)\). Finally, any such isometry must agree with \(U\) on every \(\Phi(x)\), and hence on their span and its closure by continuity. This proves uniqueness. \(\square\)

Worked Example: The Minimum Kernel and an \(L^2\) Feature Map

Take \(X=[0,\infty)\), let \(G=L^2([0,\infty))\), and define \(\psi(t)=\mathbf{1}_{[0,t]}\), where \(\mathbf{1}_{[0,t]}\) is the indicator function of the interval \([0,t]\). The inner product of two such functions is the length of the intersection of their intervals: $$ \langle\psi(s),\psi(t)\rangle_G =\int_0^\infty \mathbf{1}_{[0,s]}(r)\mathbf{1}_{[0,t]}(r)\,dr =\min(s,t). $$ Thus \(k(s,t)=\min(s,t)\) is a positive definite kernel with this feature representation.

For example, \(\|\psi(1)\|^2=1\), \(\|\psi(3)\|^2=3\), and \(\langle\psi(1),\psi(3)\rangle=1\). The squared distance is \(1+3-2(1)=2\). The canonical map has exactly the same inner products and distances: \(\|\Phi(1)-\Phi(3)\|_{\mathcal{H}_k}^2=k(1,1)+k(3,3)-2k(1,3)=1+3-2=2\). The theorem ensures that the correspondence between these feature vectors extends to an isometry between their closed spans.

Common Pitfall and Interpretation

A common mistake is to identify the feature vector \(\Phi(x)\) with the scalar \(k(x,x)\). These are different objects. The section \(\Phi(x)=k(\,\cdot\,,x)\) is a function in an RKHS; \(k(x,x)\) is a number, equal to its squared norm. For instance, in the three-point example, \(\Phi(c)\) is the function with values \((1,1,2)\), whereas \(k(c,c)=2\).

Another tempting but incorrect inference is that different inputs must have different canonical features. The distance identity shows the precise condition:

$$ \Phi(x)=\Phi(y) \quad\Longleftrightarrow\quad k(x,x)+k(y,y)-2k(x,y)=0. $$

The forward implication follows because the difference has norm zero. Conversely, a vector in a Hilbert space with squared norm zero is the zero vector, so a zero value on the right implies \(\Phi(x)-\Phi(y)=0\). Consequently, a kernel can assign identical canonical features to distinct inputs; injectivity is not automatic.

The canonical map is valuable because it gives a precise geometric interpretation of kernel values while avoiding a choice of coordinates. Any other feature representation produces the same geometry on the span of its feature vectors, up to the isometry proved above. This is the basis for carrying out feature-space inner-product calculations using only kernel evaluations.

Check Your Understanding

Use the definitions and identities above to answer the following.

  1. For a canonical feature map, what is the inner product of \(\Phi(x)\) and \(\Phi(y)\), and which RKHS property yields it?
  2. Write the squared distance between \(\Phi(x)\) and \(\Phi(y)\) using only kernel values.
  3. For \(k(x,y)=1+xy\), calculate \(k(1,-2)\) and explain why a negative value does not contradict positive definiteness.
  4. Why must the map from finite canonical-feature combinations to combinations of another feature representation be checked for well-definedness?
  5. Can two distinct inputs have the same canonical feature? State the exact condition in terms of the kernel.
Clinical Biostats