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.
Added in version 0.13.
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.
Added in version 0.24.
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.
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.
Added in version 1.0.
See also
PCA
Principal component analysis is also a latent linear variable model which however assumes equal noise variance for each feature. This extra assumption makes probabilistic PCA faster as it can be computed in closed form.
FastICA
Independent component analysis, a latent variable model with non-Gaussian latent variables.
References
David Barber, Bayesian Reasoning and Machine Learning, Algorithm 21.1.
Christopher M. Bishop: Pattern Recognition and Machine Learning, Chapter 12.2.4.
Examples
>>> 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 the FactorAnalysis model to X using SVD based approach.
Training data.
Ignored parameter.
FactorAnalysis class instance.
Fit to data, then transform it.
Fits transformer to X
and y
with optional parameters fit_params
and returns a transformed version of X
.
Input samples.
Target values (None for unsupervised transformations).
Additional fit parameters.
Transformed array.
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
.
Transformed feature names.
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.
Average log-likelihood of the samples under the current model.
Compute the log-likelihood of each sample.
The data.
Log-likelihood of each sample under the current model.
Set output container.
See Introducing the set_output API for an example on how to use the API.
Configure output of transform
and fit_transform
.
"default"
: Default output format of a transformer
"pandas"
: DataFrame output
"polars"
: Polars output
None
: Transform configuration is unchanged
Added in version 1.4: "polars"
option was added.
Estimator instance.
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.
Estimator instance.
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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4