7.2 Canonical Correlation Analysis

DATA 442/642 · Week 7 · PDF · Slides

Find paired directions that co-vary across two views.

These notes walk through the lecture slides. The original deck is unchanged; use (slides) on the course hub if you want that PDF.

Figures and notes follow Deisenroth, Faisal, and Ong, Mathematics for Machine Learning; Theodoridis; and Géron.

1. Canonical correlation analysis (CCA)

PCA reduces dimension for one data set. Often you have several related sets from different sources.

Canonical correlation analysis (CCA) processes two sets together. The correlation of two random vectors depends on the coordinate system you write them in.

CCA looks for a pair of linear maps, one per set, so that the transformed variables are maximally correlated.

Two objects to keep straight:

  • Canonical variables (variates)
  • Canonical correlation

2. The math

Two random vectors 𝐱∈ℝp and 𝐲∈ℝq, observations xn,yn for n=1,…,N.

As in PCA, start with one pair of directions, ux,1 and uy,1, that maximize the correlation of the projections.

Equivalently, the constrained problem

&maxux,uy&&ux⊤Σ^x,yuy&subject to&&ux⊤Σ^x,xux=1,uy⊤Σ^y,yuy=1,

where Σx,y is the cross-covariance.

Compared with PCA: two directions, not one; the constraints use a weighted Σ norm, not the Euclidean norm; the objective is correlation of the two projections, not variance of one.

Lagrangian:

ℒ(ux,uy,λx,λy)=ux⊤Σ^x,yuy−λx2(ux⊤Σ^x,xux−1)−λy2(uy⊤Σ^y,yuy−1).

Gradients in ux and uy set to zero give λx=λy=λ and

Σ^x,yuy=λΣ^x,xux,Σ^y,xux=λΣ^y,yuy.

Solve the second for uy (assuming Σ^y,y invertible) and substitute:

Σ^x,yΣ^y,y−1Σ^y,xux=λ2Σ^x,xux

and

uy=1λΣ^y,y−1Σ^y,xux.

If Σ^x,x is invertible too, this is an ordinary eigenproblem:

(Σ^x,x−1Σ^x,yΣ^y,y−1Σ^y,x)ux=λ2ux.

So ux,1 is an eigenvector of that product. Take the eigenvector for the largest eigenvalue λ2 to maximize the correlation.

ux,1 and uy,1 are the normalized canonical correlation basis vectors. The eigenvalue λ2 is the squared canonical correlation. The projections ux,1⊤𝐱 and uy,1⊤𝐲 are the canonical variates.


3. What to read off in practice

Two questions after you fit CCA:

  • Canonical correlation. How much is each canonical variable from set 1 correlated with its counterpart in set 2?
  • Canonical variates. Which original variables does each variate represent?

Practice

  1. CCA needs two views of the same objects. Name a pair.

  2. What is CCA maximizing that PCA is not, and what replaces the unit-Euclidean constraint?

  3. After you compute ux,1, how do you get uy,1?