Skip to main content

FactorAnalysis

A latent linear-Gaussian model that explains observed features as a few common factors plus per-feature (heteroscedastic) noise — unlike PCA, which assumes isotropic noise.

Algorithm

Loadings and noise variances are fit by expectation-maximisation. Loadings are identifiable only up to rotation, so downstream use should rely on the implied covariance or the transformed factors.

Constructor

Skigen::FactorAnalysis<Scalar> model(int n_components = 0, int max_iter = 1000, Scalar tol = 1e-3);

Parameters

ParameterDefaultDescription
n_components0Number of latent factors.
max_iter1000EM iterations.
tol1e-3Log-likelihood convergence tolerance.

Methods

MethodDescription
fit(X)Run EM.
transform(X)Project onto the latent factors.
get_covariance()Model-implied covariance.

Fitted Attributes

AccessorDescription
components()Loading matrix W.
noise_variance()Per-feature noise variance.
log_likelihood()Final log-likelihood.

Example

Skigen::FactorAnalysis<double> fa(2);
fa.fit(X);
auto Z = fa.transform(X);
Verified against scikit-learn

This estimator is checked by the parity suite. See the generator tests/parity/generate_decomposition_reference.py and the reference fixtures in tests/parity/data/factor_analysis/, exercised by tests/parity/parity_decomposition.cpp.

API Reference

For full signatures see the FactorAnalysis API Reference.