FactorAnalysis
- class sklearn.decomposition.FactorAnalysis(n_components=None, *, tol=0.01, copy=True, max_iter=1000, noise_variance_init=None, svd_method=, , ,
Factor Analysis (FA).
A simple linear generative model with Gaussian latent variables.
The observations are assumed to be caused by a linear transformation of lower dimensional latent factors and added Gaussian noise. Without loss of generality the factors are distributed according to a Gaussian with zero mean and unit covariance. The noise is also zero mean and has an arbitrary diagonal covariance matrix.
If we would restrict the model further, by assuming that the Gaussian
noise is even isotropic (all diagonal entries are the same) we would obtain
PCA.
FactorAnalysis performs a maximum likelihood estimate of the so-called
loading matrix, the transformation of the latent variables to the
observed ones, using SVD based approach.
Read more in the User Guide.
Dimensionality of latent space, the number of components
of X that are obtained after transform.
If None, n_components is set to the number of features.
Stopping tolerance for log-likelihood increase.
Whether to make a copy of X. If False, the input X gets overwritten
during fitting.
Maximum number of iterations.
The initial guess of the noise variance for each feature. If None, it defaults to np.ones(n_features).
Which SVD method to use. If ‘lapack’ use standard SVD from
scipy.linalg, if ‘randomized’ use fast randomized_svd function.
Defaults to ‘randomized’. For most applications ‘randomized’ will
be sufficiently precise while providing significant speed gains.
Accuracy can also be improved by setting higher values for
iterated_power. If this is not sufficient, for maximum precision
you should choose ‘lapack’.
Number of iterations for the power method. 3 by default. Only used
if svd_method equals ‘randomized’.
If not None, apply the indicated rotation. Currently, varimax and quartimax are implemented. See “The varimax criterion for analytic rotation in factor analysis” H. F. Kaiser, 1958.
Only used when svd_method equals ‘randomized’. Pass an int for
reproducible results across multiple function calls.
See Glossary.
Components with maximum variance.
The log likelihood at each iteration.
The estimated noise variance for each feature.
Number of iterations run.
Per-feature empirical mean, estimated from the training set.
Number of features seen during fit.
David Barber, Bayesian Reasoning and Machine Learning, Algorithm 21.1.
Christopher M. Bishop: Pattern Recognition and Machine Learning, Chapter 12.2.4.
>>> from sklearn.datasets import load_digits
>>> from sklearn.decomposition import FactorAnalysis
>>> X, _ = load_digits(return_X_y=True)
>>> transformer = FactorAnalysis(n_components=7, random_state=0
Fit the FactorAnalysis model to X using SVD based approach.
Training data.
Ignored parameter.
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params
and returns a transformed version of X.
Compute data covariance with the FactorAnalysis model.
cov = components_.T * components_ + diag(noise_variance)
Estimated covariance of data.
Get output feature names for transformation.
The feature names out will prefixed by the lowercased class name. For
example, if the transformer outputs 3 features, then the feature names
out are: ["class_name0", "class_name1", "class_name2"].
Only used to validate feature names with the names seen in fit.
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
A MetadataRequest encapsulating
routing information.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Compute data precision matrix with the FactorAnalysis model.
Estimated precision of data.
Compute the average log-likelihood of the samples.
The data.
Ignored parameter.
Compute the log-likelihood of each sample.
The data.
Log-likelihood of each sample under the current model.
Set output container.
Refer to the user guide for more details and Introducing the set_output API for an example on how to use the API.
Configure output of transform and .
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects
(such as Pipeline). The latter have
parameters of the form <component>__<parameter> so that it’s
possible to update each component of a nested object.
Estimator parameters.
Apply dimensionality reduction to X using the model.
Compute the expected mean of the latent variables. See Barber, 21.2.33 (or Bishop, 12.66).
Training data.
The latent variables of X.
Model selection with Probabilistic PCA and Factor Analysis (FA)
Factor Analysis (with rotation) to visualize patterns
Added in version 0.24.
n_features_in_,)Names of features seen during fit. Defined only when X
has feature names that are all strings.
FactorAnalysis class instance.
Input samples.
Target values (None for unsupervised transformations).
Additional fit parameters.
Pass only if the estimator accepts additional params in its fit method.
Transformed array.
Transformed feature names.
Average log-likelihood of the samples under the current model.
"default": Default output format of a transformer
"pandas": DataFrame output
"polars": Polars output
None: Transform configuration is unchanged
Estimator instance.
Estimator instance.