class sklearn.decomposition.FactorAnalysis(n_components=None, tol=0.01, copy=True, max_iter=1000, noise_variance_init=None, svd_method=’randomized’, iterated_power=3, random_state=0)
[source]
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 PPCA
.
FactorAnalysis performs a maximum likelihood estimate of the so-called loading
matrix, the transformation of the latent variables to the observed ones, using expectation-maximization (EM).
Read more in the User Guide.
Parameters: |
|
---|---|
Attributes: |
|
See also
PCA
FastICA
>>> 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) >>> X_transformed = transformer.fit_transform(X) >>> X_transformed.shape (1797, 7)
fit (X[, y]) | Fit the FactorAnalysis model to X using EM |
fit_transform (X[, y]) | Fit to data, then transform it. |
get_covariance () | Compute data covariance with the FactorAnalysis model. |
get_params ([deep]) | Get parameters for this estimator. |
get_precision () | Compute data precision matrix with the FactorAnalysis model. |
score (X[, y]) | Compute the average log-likelihood of the samples |
score_samples (X) | Compute the log-likelihood of each sample |
set_params (**params) | Set the parameters of this estimator. |
transform (X) | Apply dimensionality reduction to X using the model. |
__init__(n_components=None, tol=0.01, copy=True, max_iter=1000, noise_variance_init=None, svd_method=’randomized’, iterated_power=3, random_state=0)
[source]
fit(X, y=None)
[source]
Fit the FactorAnalysis model to X using EM
Parameters: |
|
---|---|
Returns: |
|
fit_transform(X, y=None, **fit_params)
[source]
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Parameters: |
|
---|---|
Returns: |
|
get_covariance()
[source]
Compute data covariance with the FactorAnalysis model.
cov = components_.T * components_ + diag(noise_variance)
Returns: |
|
---|
get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: |
|
---|---|
Returns: |
|
get_precision()
[source]
Compute data precision matrix with the FactorAnalysis model.
Returns: |
|
---|
score(X, y=None)
[source]
Compute the average log-likelihood of the samples
Parameters: |
|
---|---|
Returns: |
|
score_samples(X)
[source]
Compute the log-likelihood of each sample
Parameters: |
|
---|---|
Returns: |
|
set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: |
|
---|
transform(X)
[source]
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).
Parameters: |
|
---|---|
Returns: |
|
sklearn.decomposition.FactorAnalysis
© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.FactorAnalysis.html