Linear latent representations#

The six unsupervised linear reducers answer different questions. PCA preserves sample variance, Gaussian projection offers a data-independent randomized map, FA and PPCA specify Gaussian latent-variable models, FastICA searches for independent sources, and Sparse PCA trades reconstruction against sparse loadings [Bingham and Mannila, 2001, Hyvärinen, 1999, Pearson, 1901, Rubin and Thayer, 1982, Tipping and Bishop, 1999, Zou et al., 2006].

For PCA, the fitted coordinates have the centered linear form

\[Z = (X - \mu) V_k^{\mathsf{T}}.\]

We use one deterministic two-factor dataset for a compact comparison.

import numpy as np

from believe14.linear import (
    PCA,
    FactorAnalysis,
    FastICA,
    GaussianRandomProjection,
    ProbabilisticPCA,
    SparsePCA,
)

rng = np.random.default_rng(14)
latent = rng.normal(size=(100, 2))
mixing = np.array(
    [[1.2, -0.4, 0.9, 0.0, 0.2, 0.4], [0.0, 0.7, 0.2, 1.1, -0.5, 0.3]]
)
X = latent @ mixing + 0.08 * rng.normal(size=(100, 6))

models = [
    PCA(2),
    GaussianRandomProjection(2, random_state=14),
    FactorAnalysis(2, max_iter=1000),
    ProbabilisticPCA(2),
    FastICA(2, random_state=14, max_iter=1000),
    SparsePCA(2, alpha=0.02, max_iter=1000),
]

for model in models:
    scores = model.fit_transform(X)
    assert scores.shape == (100, 2)
    assert np.isfinite(scores).all()
    print(
        f"{type(model).__name__:28s}",
        f"solver={model.diagnostics_.solver:24s}",
        f"converged={model.diagnostics_.converged}",
    )
PCA                          solver=centered_svd             converged=True
GaussianRandomProjection     solver=gaussian_projection      converged=True
FactorAnalysis               solver=rubin_thayer_em          converged=True
ProbabilisticPCA             solver=closed_form_ml           converged=True
FastICA                      solver=symmetric_fastica        converged=False
SparsePCA                    solver=alternating_elastic_net  converged=True

All six expose transform because their fitted model defines a global linear map. PCA, FA, PPCA, and FastICA additionally expose a mathematically defined inverse_transform; projection and sparse-component models do not promise an exact inverse. Components are identifiable only up to the equivalence stated in each method’s validation ledger.

Use the fitted inverse_transform to restore the original feature units. PCA, FA, PPCA, and FastICA retain a reference and a small centering offset, then combine them with compensated arithmetic during reconstruction. This reduces rounding loss when small variations sit around a large baseline. Manually adding the rounded mean_ to centered coordinates can lose those variations. FA and PPCA still return reconstructions under their fitted latent models; restoring the offset does not remove model approximation or noise.

Use the cards for PCA, Gaussian projection, Factor Analysis, PPCA, FastICA, and Sparse PCA to inspect fitted attributes and failure boundaries.