Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.What do two sets of measurements have in common?
Suppose an aircraft carries two independent sensor suites, or you have both images and maintenance notes for each part. CCA looks for a combination of the first set’s variables and a combination of the second set’s that move together as closely as possible. It then finds a second pair, unrelated to the first, and so on. Each pair reveals a shared signal behind the two views, along with how strongly they agree on it.
Cross-checking redundant sensor suites, finding which input variables drive which outputs, fusing multimodal data, and calibrating one instrument against another are all “two views of one system” problems. CCA quantifies the shared structure, and its regularised, kernel and deep variants underlie modern multiview learning.
- 1. CCA relates…
- 2. The first canonical pair is chosen to be…
- 3. With few samples and many variables, CCA's training correlation is…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Canonical correlations by hand
One variable per view. CCA reduces to the absolute Pearson correlation.
A shared latent signal. If x = z + e₁ and y = z + e₂, with unit-variance z and independent noises of variances σ₁² and σ₂²:
corr(x, y) = 1/√((1 + σ₁²)(1 + σ₂²)).
- Noise variances 0.25 and 0.25 give 0.8.
- 1 and 1 give 0.5.
- 0.25 and 1 give 0.632.
Whitening. Σ^(−½) for diag(4, 9) is diag(0.5, 1/3). After whitening each view, the canonical correlations are the singular values of the whitened cross-covariance.
Number of pairs. At most min(p, q). With few samples, also at most n − 1 non-trivial ones. For p = q = 20 and n = 10: 9.
The steps in plain English:
- Centre both views and compute Σxx, Σyy and Σxy, adding a ridge to Σxx and Σyy if n is not much larger than p + q.
- Form M = Σxx^(−½) Σxy Σyy^(−½) and take its SVD, M = U S Vᵀ.
- Canonical correlations are the diagonal of S. The directions are a = Σxx^(−½) uᵢ and b = Σyy^(−½) vᵢ.
- Report canonical variates Xa and Yb, check correlations on held-out data, and interpret the loadings (correlations of the original variables with the variates).
- 1. corr(z + e₁, z + e₂) with noise variances 3 and 0?
- 2. Maximum canonical pairs for p = 3, q = 5, n = 100?
- 3. CCA with one variable per view gives…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Why the SVD, invariance, and overfitting
Derivation. Maximise corr(Xa, Yb) = aᵀΣxy b / √(aᵀΣxx a · bᵀΣyy b). Substituting ã = Σxx^½a and b̃ = Σyy^½b, this becomes ãᵀMb̃ / (‖ã‖‖b̃‖), which the top singular pair of M maximises. Later pairs are the next singular pairs. They are automatically uncorrelated with earlier variates within each view, and across views except for their own partner.
Invariance. Replacing X by XA for any invertible A leaves the canonical correlations unchanged. Exercise 1 mixed each view with an arbitrary linear map, and CCA still recovered the theoretical correlations: 0.793 and 0.502 against 0.8 and 0.5, and 0.007 for the third, which should be 0.
That invariance is a double-edged sword. CCA will happily amplify any direction, however noisy, if it raises the correlation.
Overfitting. With n ≤ p + q, there are directions giving perfect training correlation, even for independent views. In exercise 2 (two 20-D views, true canonical correlation 0.6):
- with n = 30, plain CCA reported 1.000 on the training data and only 0.02–0.03 on fresh data;
- ridge regularisation (λ = 0.5) lowered the training value to 0.74 and raised the fresh-data value to 0.17;
- only by n of about 2000 did training and fresh-data correlation agree at 0.6.
Regularised CCA. Use Σxx + λ(tr Σxx/p)I, and likewise for Σyy. As λ → ∞, CCA approaches PLS-SVD, which maximises covariance instead of correlation. Choose λ by cross-validating the held-out canonical correlation.
Relations.
- If Y is one-hot class labels, CCA’s X-directions are Fisher’s LDA directions.
- With one-dimensional Y, the first canonical correlation is the multiple correlation R from regressing Y on X.
- Kernel CCA and deep CCA find nonlinear shared structure, and need even stronger regularisation.
from sklearn.cross_decomposition import CCA
cca = CCA(n_components=2).fit(X_train, Y_train) # (unregularised)
U, V = cca.transform(X_test, Y_test) # check correlations on held-out data!- 1. Canonical correlations are the singular values of…
- 2. With n ≤ p + q, plain CCA can reach a training correlation of…
- 3. As the ridge λ → ∞, CCA approaches…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Sampling distribution. Under independence (true correlation 0), the largest sample canonical correlation is large when p and q are comparable to n, following Wachter or Jacobi-ensemble limits. Classic tests:
- Bartlett’s χ² approximation for the number of significant pairs, −(n − 1 − (p + q + 1)/2) Σ log(1 − ρᵢ²);
- Wilks’ Λ.
Both are reliable only when n is large relative to p + q. Otherwise use permutation tests: shuffle one view’s rows.
Probabilistic CCA. Bach and Jordan (2005) showed that CCA is the maximum-likelihood solution of a latent-variable model with a shared Gaussian latent and view-specific noise. That is the two-view analogue of probabilistic PCA, and it allows priors, missing data and Bayesian versions.
Interview questions.
- How would you test whether two sensor suites share information? Use regularised CCA on training data, evaluate the canonical correlations on held-out data or by permutation, and report the loadings for the significant pairs.
- CCA, PLS or regression? Regression to predict one view from the other. CCA for symmetric shared structure, correlation-based and scale-free. PLS when you want covariance-weighted directions that are more stable with many correlated variables.
- 1. A robust way to test canonical correlations when n is small is…
- 2. Probabilistic CCA posits…
- 3. If Y is one-hot class labels, CCA's X-directions match…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.How badly does CCA overfit?
History.
- H. Hotelling introduced canonical correlations (1936).
- M. Bartlett (1941) gave significance tests.
- H. Vinod (1976) proposed ridge (canonical ridge) regularisation.
- F. Bach and M. Jordan (2002, 2005) developed kernel CCA and probabilistic CCA.
- G. Andrew et al. (2013) introduced deep CCA.
Exercise 2. Two 20-D views sharing one latent signal (true first canonical correlation 0.6), 4 datasets. Each cell shows the first canonical correlation on the training data, then on 3000 fresh samples.
| n | plain (λ = 0) | λ = 0.1 | λ = 0.5 |
|---|---|---|---|
| 30 | 1.000, 0.029† | 0.926, 0.126 | 0.741, 0.167 |
| 60 | 0.941, 0.093 | 0.853, 0.216 | 0.669, 0.321 |
| 120 | 0.768, 0.380 | 0.712, 0.429 | 0.563, 0.467 |
| 480 | 0.652, 0.551 | 0.611, 0.556 | 0.491, 0.564 |
| 2000 | 0.606, 0.597 | 0.570, 0.597 | 0.460, 0.599 |
† At n = 30 plain CCA inverts a singular covariance, so this value depends on rounding: the in-browser Python gives 0.016.
- With fewer samples than variables (30 < 40), plain CCA reported perfect correlation that did not exist on new data.
- Regularisation always improved the fresh-data correlation when n was small, at the cost of a lower (biased) training value. Never trust a training canonical correlation without held-out checks.
- Even at n = 480 (12 samples per variable), the training value overstated the truth (0.65 against a held-out 0.55).
CCA in AI, robotics and aerospace
- Redundant-sensor consistency: canonical correlations between two independent suites drop when one degrades.
- Multimodal fusion: aligning camera and lidar features, or images and text, in a shared space (deep CCA).
- Input–output analysis: finding which control-input combinations drive which response combinations.
References
- H. Hotelling (1936). “Relations between two sets of variates.” Biometrika 28(3/4).
- F. R. Bach, M. I. Jordan (2005). “A probabilistic interpretation of canonical correlation analysis.” Technical report 688, UC Berkeley.
- D. R. Hardoon, S. Szedmak, J. Shawe-Taylor (2004). “Canonical correlation analysis: an overview with application to learning methods.” Neural Computation 16(12).
- G. Andrew, R. Arora, J. Bilmes, K. Livescu (2013). “Deep canonical correlation analysis.” Proc. ICML.
- H. D. Vinod (1976). “Canonical ridge and econometrics of joint production.” Journal of Econometrics 4(2).