Foundations to Frontier
Tests
D. Classical Machine Learning › D9 Dimensionality Reduction and Manifold Learning

Probabilistic PCA

Probabilistic PCA (Tipping and Bishop, 1999) recasts PCA as a latent-variable model: each observation is a linear map W of a low-dimensional Gaussian latent vector, plus a mean, plus isotropic Gaussian noise of variance σ². Its maximum-likelihood solution has a closed form: W spans the top principal directions, scaled by the square root of each eigenvalue minus σ², and σ² is the average of the discarded eigenvalues. So PCA is recovered as the zero-noise limit. The probabilistic view gives a likelihood (for model comparison and choosing the dimension), posterior latent coordinates with uncertainty, an EM algorithm that handles missing data, mixtures of PPCAs, and the bridge to factor analysis and Bayesian PCA. In the exercises you derive the closed form and confirm EM converges to it; then you choose the latent dimension by BIC and held-out likelihood and compare with the eigenvalue rules from the PCA topic.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

PCA as a story about how data were made

Imagine each data point was produced in three steps:

  1. Draw a few hidden numbers z, say 3 of them.
  2. Spread them into the full measurement space with a fixed matrix W.
  3. Add a little random noise in every direction.

Probabilistic PCA fits that story. Its best-fitting W spans exactly the PCA directions, and the noise level comes out as the leftover variance. Because it’s a full probability model, it can say how likely new data are, how many hidden dimensions the data support, and how uncertain each point’s hidden coordinates are.

Probabilistic PCA: PCA as a Gaussian model with noise
fitted noise variance σ² 0.345 (true 0.360) · ‖W‖ 1.98 · posterior shrinkage 0.919
The fitted model is the shaded ellipse: a Gaussian whose long axis is W and whose width is the noise. For 12 points, blue marks PCA's orthogonal projection onto the axis, and orange the PPCA posterior mean of the latent coordinate mapped back onto the axis. Posterior means are pulled toward the centre by ‖W‖²/(‖W‖² + σ²): with little noise they match PCA, and with more noise PPCA trusts each point's position less. The noise estimate σ² is the variance left over in the discarded direction.
Why engineers care

A likelihood turns PCA into something you can test. You can score how normal a new telemetry snapshot is, compare models with different numbers of components, fill in missing sensor readings, and combine several local PCA models into a mixture. PPCA is the backbone of probabilistic monitoring and of many latent-variable models used for sensor fusion.

📝 Quick check (Level 0)
0/3 answered
  1. 1. PPCA models data as…
  2. 2. Its best-fitting W spans…
  3. 3. PPCA adds to PCA…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

The closed form by hand

Model. x = Wz + μ + ε, with z ~ N(0, I_q) and ε ~ N(0, σ²I). Marginally, x ~ N(μ, C) with C = WWᵀ + σ²I. For W = (1, 2)ᵀ and σ² = 0.5, C = [[1.5, 2], [2, 4.5]].

Maximum likelihood (Tipping and Bishop):

  • σ² = the average of the d − q smallest eigenvalues of the sample covariance;
  • W = U_q (Λ_q − σ²I)^½ R, for any rotation R.

With eigenvalues 10, 5, 1, 1.2, 0.8 and q = 2: σ² = (1 + 1.2 + 0.8)/3 = 1, and the columns of W have lengths √(10 − 1) = 3 and √(5 − 1) = 2.

Posterior over the latent. E[z | x] = M⁻¹Wᵀ(x − μ), with M = WᵀW + σ²I. For W = (1, 0)ᵀ, σ² = 1 and x = (3, 0): M = 2, so E[z | x] = 1.5, half of PCA’s coordinate 3. That is shrinkage toward the prior mean.

Parameter count. dq − q(q − 1)/2 (W up to rotation), + 1 (σ²), + d (mean). For d = 10 and q = 3: 30 − 3 + 1 + 10 = 38.

The steps in plain English:

  1. Compute the sample covariance and its eigendecomposition.
  2. Choose q. Set σ² to the mean of the discarded eigenvalues, and W to the top q eigenvectors scaled by √(λ − σ²).
  3. Use the Gaussian likelihood of C = WWᵀ + σ²I for model comparison, or to score new points.
  4. For missing data or very large d, fit by EM instead of the closed form.
📝 Quick check (Level 1)
0/3 answered
  1. 1. ML σ² for eigenvalues 6, 2, 1, 1 with q = 2?
  2. 2. Length of the first W column for λ₁ = 6, σ² = 1?
  3. 3. PPCA posterior means compared with PCA coordinates are…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.

Why the closed form, EM, and what the likelihood gives

Deriving the ML solution. The log-likelihood is −(n/2)(d log 2π + log|C| + tr(C⁻¹S)). Setting its gradient with respect to W to zero gives SC⁻¹W = W. The non-trivial solutions put the columns of W on eigenvectors of S, with lengths √(λᵢ − σ²). The maximum keeps the q largest eigenvalues. Substituting back, σ² equals the mean of the rest. At that solution log|C| = Σᵢ≤q log λᵢ + (d − q) log σ² and tr(C⁻¹S) = d.

As σ² → 0 the posterior mean becomes (WᵀW)⁻¹Wᵀ(x − μ), the orthogonal projection: standard PCA.

EM.

  • E-step: posterior means and second moments of z.
  • M-step: W = (Σ x zᵀ)(Σ z zᵀ)⁻¹ and an update for σ².

Each iteration costs O(ndq). There is no d × d covariance, so it suits large d, and it handles missing entries naturally. Exercise 1, from a random start, reached the closed-form likelihood (−6806.1) with the same σ² (0.2448) and the same subspace.

Choosing q. The training likelihood always increases with q; in exercise 1 it kept creeping up after the true q = 3. So use instead:

  • BIC, with dq − q(q − 1)/2 + 1 + d parameters;
  • held-out (cross-validated) likelihood;
  • Minka’s Laplace approximation, or Bayesian PCA with automatic relevance determination.

Exercise 2 used the rank-5 data from the PCA topic. BIC and held-out likelihood were exact at low and moderate noise. At high noise they were conservative (q = 3), while Kaiser’s rule overcounted (8.6).

from sklearn.decomposition import PCA
pca = PCA(n_components=5).fit(X)
pca.noise_variance_                       # PPCA's σ² (mean of discarded eigenvalues)
pca.score(X_new)                          # average PPCA log-likelihood per sample
PCA(n_components="mle").fit(X)            # Minka's automatic choice of q
🐍 Exercise 1: probabilistic PCA
Implement the closed-form ML solution, the PPCA log-likelihood and EM; check EM reaches the closed form, that σ² recovers the noise, and that training likelihood can't choose q.
📝 Quick check (Level 2)
0/3 answered
  1. 1. As σ² → 0, PPCA becomes…
  2. 2. Why use EM rather than the closed form?
  3. 3. Training likelihood as a function of q…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Rotational non-identifiability. If W fits, so does WR for any orthogonal R, because C depends only on WWᵀ. The subspace is identified; individual columns are not, unless you impose an ordering.

Relation to factor analysis. Factor analysis replaces σ²I by a diagonal Ψ (a separate noise variance per variable). That makes it invariant to rescaling variables but not to rotation, whereas PPCA is the reverse. FA has no closed form and needs EM (next topic).

Mixtures and Bayesian PCA.

  • A mixture of PPCAs (Tipping and Bishop) models data on several local linear patches. It is a constrained GMM with q-dimensional plus isotropic covariances, fewer parameters than full covariances.
  • Bayesian PCA puts priors on the columns of W, and the posterior switches off unneeded columns (automatic relevance determination).

Interview questions.

  • What does PPCA add over PCA? A likelihood (anomaly scores, model selection, comparison with other models), handling of missing data, posterior uncertainty, and building blocks for mixtures and Bayesian extensions.
  • How do you score a new point’s normality? By its log-density under N(μ, WWᵀ + σ²I). This decomposes into a Mahalanobis term within the subspace and a residual term off it, similar to T² and SPE.
📝 Quick check (Level 3)
0/3 answered
  1. 1. PPCA's W is identified only up to…
  2. 2. Factor analysis differs from PPCA by using…
  3. 3. Bayesian PCA chooses q via…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Can the likelihood pick the dimension?

History.

  • M. Tipping and C. Bishop (1999) introduced PPCA and mixtures of PPCA.
  • S. Roweis (1998) independently proposed EM for PCA.
  • C. Bishop (1999) developed Bayesian PCA.
  • T. Minka (2000) gave an automatic choice of dimension via the Laplace approximation; it is in scikit-learn as n_components=“mle”.

Exercise 2. The same data as the PCA topic: true rank 5 in 30 dimensions, n = 200, 5 datasets per noise level, q from 1 to 15. Held-out likelihood used two 50/50 folds. Each cell shows the mean chosen q and, in brackets, how often it was exactly 5.

noise σ PPCA BIC PPCA held-out likelihood Kaiser (λ > 1)
0.3 5.0 (100%) 5.0 (100%) 5.0 (100%)
0.7 5.0 (100%) 5.0 (100%) 5.0 (100%)
1.2 4.4 (40%) 4.6 (60%) 5.4 (60%)
2.0 3.0 (0%) 3.0 (0%) 8.6 (0%)
  • Likelihood-based choices were exact while the signal was clear, and never overcounted at any noise level.
  • At high noise they dropped the two weakest components (variances 4 and 2.25 against noise variance 4): estimating a component’s 30 loadings from 100 samples per fold cost more likelihood than the component gained. Kaiser erred the other way.
  • The likelihood answers “what predicts new data best at this sample size?” That can differ from the true rank when components are weak.
🐍 Exercise 2 (research): choosing q by likelihood
On rank-5 data in 30-D with increasing noise, choose the PPCA dimension by BIC and by two-fold held-out likelihood, and compare with Kaiser's rule.

Probabilistic PCA in AI, robotics and aerospace

  • Probabilistic monitoring: log-likelihood under a PPCA model of normal operation as a single anomaly score.
  • Missing-data imputation for sensor dropouts via EM and posterior means.
  • Mixtures of PPCA for multi-regime systems, a local linear model per operating mode.

References

  1. M. E. Tipping, C. M. Bishop (1999). “Probabilistic principal component analysis.” JRSS B 61(3).
  2. M. E. Tipping, C. M. Bishop (1999). “Mixtures of probabilistic principal component analyzers.” Neural Computation 11(2).
  3. S. Roweis (1998). “EM algorithms for PCA and SPCA.” NeurIPS 10.
  4. C. M. Bishop (1999). “Bayesian PCA.” NeurIPS 11.
  5. T. P. Minka (2000). “Automatic choice of dimensionality for PCA.” NeurIPS 13.