Linear Algebra
9.208 min read

Principal Coordinates from Gram Matrix

The Gram matrix G=AAG = A^\top A has spectral decomposition G=VΛGVG = V\Lambda_G V^\top with eigenvalues σi2\sigma_i^2. Principal coordinates can be recovered directly: columns of VkΛG,k1/2V_k \Lambda_{G,k}^{1/2} give the scores. This requires only pairwise inner products Gij=aiajG_{ij} = \mathbf{a}_i^\top \mathbf{a}_j, not raw data vectors.

This is the key insight behind kernel PCA: replace Gij=aiajG_{ij} = \mathbf{a}_i^\top \mathbf{a}_j with Kij=k(ai,aj)K_{ij} = k(\mathbf{a}_i, \mathbf{a}_j) for a kernel function to get non-linear principal coordinates.

Formal View

Theorem 9.7 — Principal Coordinates from Gram
Let G=AA=VΛGVG = A^\top A = V\Lambda_G V^\top. Principal coordinates: columns of Ck=VkΛG,k1/2C_k^\top = V_k \Lambda_{G,k}^{1/2}.

Kernel PCA uses Kij=k(ai,aj)K_{ij} = k(\mathbf{a}_i, \mathbf{a}_j) instead of Gij=aiajG_{ij} = \mathbf{a}_i^\top \mathbf{a}_j.

Interactive Visualization

Matrix Product — Column Perspective

Why This Matters

Gram-matrix PCA enables kernel PCA and non-linear dimensionality reduction.

  • Kernel PCA: non-linear principal coordinates via kernel functions.
  • When mNm \gg N: only the N×NN \times N Gram matrix is needed.
  • Metric embeddings: recover coordinates from pairwise inner products.

Quiz

Question 1

Principal coordinates can be computed from G=AAG = A^\top A without knowing the raw data vectors ai\mathbf{a}_i.

Question 2

Kernel PCA replaces Gij=aiajG_{ij} = \mathbf{a}_i^\top \mathbf{a}_j with:

Common Mistakes

  • Forgetting to center the Gram matrix before kernel PCA.
  • Confusing AAA^\top A (Gram) with AAAA^\top (covariance).