An unlabelled collection of sensor traces has no target column to predict. Yet some traces vary together, some are unusual, and the apparent dimension may greatly exceed the number of underlying modes. Learning can now mean finding coordinates, groups or a probability distribution rather than an input–output map.
In supervised learning, pairs constrain a conditional prediction, such as . In unsupervised learning, observations alone supply the structure to be learned. Clustering, dimensionality reduction, density modelling and anomaly detection are different tasks within this setting. Not every unsupervised method maximises a marginal likelihood: ordinary PCA and -means have geometric objectives, although probabilistic relatives exist.
In this chapter: PCA, reconstruction, probabilistic PCA, nonlinear latent models.
Which direction loses the least information?
Let , , and use the covariance convention
This is the empirical covariance with divisor , not the unbiased population-covariance estimator with divisor . For a unit vector , the centred projected coordinates have empirical variance . To retain as much variance as possible in one coordinate, maximise this quadratic form subject to .
A Lagrange multiplier gives . The spectral theorem orders the eigenvalues , and the maximum is at a leading eigenvector. Requiring later directions to be orthogonal gives the remaining eigenvectors. Their signs are arbitrary; equal eigenvalues allow rotations within a tied eigenspace. The resulting principal subspace is unique only when the retained and discarded eigenvalues are separated.
This construction makes a geometric claim: a direction with a wide spread of projected data is more useful for compression than one with little spread. It does not claim that high variance is scientifically important. Feature scaling changes , and a large-variance nuisance can dominate a small but predictive signal.
Rotate the candidate axis before accepting the leading eigenvector. Every retained coordinate grows at the expense of a perpendicular residual. The variation curve below records exactly the same operation as the geometric projection, and makes the maximum at the principal direction visible.
retained variance = uᵀSu · retained + discarded = tr(S)
retained = 2.000discarded = 2.000; total = 4.0
Maximum variance is minimum squared reconstruction error
Collect the first orthonormal eigenvectors into . A point is encoded and reconstructed by
The discarded residual is perpendicular to the retained subspace. Pythagoras gives
Thus PCA minimises mean squared reconstruction error among rank- orthogonal projections. Total squared error is times this sum; the normalisation must not be lost. For a data matrix with uncentred rows , the matrix formulas are
A thin SVD computes the principal directions without forming ; . The mean and basis fitted on training data are reused on test data, rather than recomputed jointly with it.
Compare the retained and discarded directions for . Keeping the diagonal direction retains variance three and discards variance one. The cloud is a deterministic teaching construction with exactly this empirical covariance, not a random sample from a Gaussian.
PCA supports visualisation, compressed storage, decorrelation and reconstruction-based anomaly scores. Compression must also store the mean and basis. Decorrelation is not independence except in special distributions such as a joint Gaussian. An unusual point may have small reconstruction error while lying far along the principal subspace; anomaly detection should consider both retained coordinates and discarded residuals. Linear projection cannot unfold a curved manifold. Kernel PCA changes the feature geometry, while nonlinear decoders learn an explicit generative map.
A subspace is not yet a distribution
Ordinary PCA says how to project an observed point, but not how frequently different points should occur. A latent-variable model supplies a generative mechanism:
Probabilistic PCA chooses
with independent and . Its marginal is . Latent variation accounts for the dominant directions; isotropic noise fills the rest. For the distribution has full-dimensional support, so the data do not literally lie on a plane.
Under the usual interior solution, maximum likelihood gives
where is any orthogonal matrix. Latent rotations are not identifiable. The covariance fits leading eigenvalues individually and replaces all discarded eigenvalues by their average; this explains the noise estimate. Boundary cases with zero noise can be singular and need separate treatment. These formulas and their likelihood interpretation come from Tipping and Bishop's probabilistic PCA.
Conditioning is also analytic. With ,
As noise tends to zero with full column rank, decoding the posterior mean approaches the orthogonal PCA reconstruction. The latent coordinates can remain scaled and rotated relative to ordinary PCA scores; the full probability model becomes singular in that limit. “Recovers PCA” refers to the principal subspace and reconstruction, not identical coordinates and a nonsingular density.
Generation now has an unambiguous recipe: independently draw and , then return . Omitting noise generates only the low-rank component. The source describes MNIST1D samples with thirty components; without its data we cannot assess their resemblance. A single Gaussian can reproduce covariance while still mixing distinct digit classes into implausible samples.
Bending the generative map
Replace by a network decoder :
The mean map can represent curved structure and sometimes use fewer latent dimensions for a given reconstruction error. But nonlinearity generally removes Gaussian conjugacy: the posterior and marginal integral are usually intractable. This is not true for every nonlinear model, and flexibility does not guarantee better generation, identifiable latent factors or the ability to represent arbitrary topology with a chosen continuous decoder.
Keep a collection of latent draws fixed while bending their decoder. The resulting motion separates three objects that can otherwise be conflated: the latent prior, the decoder mean and observation noise. Nonlinearity changes the map into data space; it need not change the prior at all.
z ∼ N(0,1) · x = (z, b(z² − 1)) + ε
curvature b = 0.00noise σ = 0.08
For clustering, a Gaussian mixture instead uses a discrete latent class and a distribution within each class. -means can be viewed through a limiting hard-assignment construction, but centres alone are not a normalised generative distribution. GANs, flows and diffusion models offer other generative formulations; they need not use the Gaussian decoder likelihood above or the same training objective.
A nonlinear decoder trained only with a reconstruction objective is not yet a variational autoencoder. We still need a distribution over latent codes, a way to infer them from observations, and an objective relating that inference to data probability. The final chapter builds those pieces and makes their approximation error explicit.