6.3 Special Considerations for PCA

DATA 442/642 · Week 6 · PDF · Slides

Centering, scaling, and how many components to keep.

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. PCA and singular value decomposition (SVD)

Eigendecomposition. From the covariance 𝐒=1N∑n=1Nxnxn⊤, compute eigenvalues λi and eigenvectors ui. The ui are the principal components. Each λi is the variance along that component.

SVD. Factor the centered data matrix: 𝐗=𝐔Σ𝐕⊤. The right singular vectors 𝐕 are the principal components. The singular values on the diagonal of Σ are the square roots of the eigenvalues of 𝐗⊤𝐗.

The two routes agree. That is the link between the maximum-variance view of PCA and the SVD of 𝐗.


2. PCA and low-rank approximations

Because 𝐗^ is the best rank-m approximation of 𝐗 in the Frobenius sense,

‖𝐗^−𝐗‖F2=∑n=1N‖x^n−xn‖2

is minimum.

So PCA also minimizes the sum of squared reconstruction errors. The same components that maximize variance are the ones that keep as much of the original points as an m-dimensional picture can.


3. Latent variable perspective

So far PCA had no probabilistic model: maximum variance and projection only. A probabilistic model would:

  • come with a likelihood, so noise in the observations is explicit;
  • allow Bayesian model comparison via the marginal likelihood;
  • treat PCA as a generative model (simulate new data);
  • make connections to related algorithms straightforward;
  • handle dimensions missing at random by Bayes;
  • give a notion of how novel a new point is;
  • extend cleanly, e.g. to a mixture of PCA models;
  • recover the PCA of the earlier sections as a special case;
  • allow a fully Bayesian treatment by integrating out parameters.

4. History of probabilistic PCA

A continuous latent z∈ℝM lets you write PCA as a probabilistic latent-variable model. Tipping and Bishop (1999) called this probabilistic PCA (PPCA). It addresses most of the list above. Ordinary PCA — maximize projected variance, or minimize reconstruction error — is maximum likelihood in the noise-free limit.


5. The PPCA model

Assume a continuous latent z∈ℝM with standard-normal prior p(z)=𝒩(0,𝐈), and a linear map to the observation x:

x=Bz+μ+ϵ∈ℝD,

where ϵ~𝒩(0,σ2𝐈) is Gaussian observation noise, B∈ℝD×M, and μ∈ℝD. The conditional is

p(x∣z;B,μ,σ2)=𝒩(x∣Bz+μ,σ2𝐈).

The generative process:

zn~𝒩(z∣0,𝐈)

and

xn∣zn~𝒩(x∣Bzn+μ,σ2𝐈).

To draw a typical point, use ancestral sampling: first zn~p(z), then xn~p(x∣zn;B,μ,σ2).

The joint is

p(x,z∣B,μ,σ2)=p(x∣z,B,μ,σ2)p(z).

6. An illustration of PPCA

Blue dots: two-dimensional PCA latents for MNIST digits “8”. Query any z* in that plane and generate x~*=Bz* (here μ=0 and identity covariance). The image looks like an “8”.

PPCA latent space and generated eights

Eight generated images sit with their latent coordinates. Where you query the latent plane changes shape, rotation, size.


Practice

  1. In the SVD view of PCA, which factor of 𝐗=𝐔Σ𝐕⊤ holds the principal components?

  2. Besides maximizing variance, what reconstruction quantity does a rank-m PCA minimize?

  3. In PPCA, what extra random object appears that ordinary PCA never named, and what prior does it get?