DocumentationClassesFactorAnalysis

Class: FactorAnalysis

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.

Python Reference

Constructors

new FactorAnalysis()

new FactorAnalysis(opts?): FactorAnalysis

Parameters

ParameterTypeDescription
opts?object-
opts.copy?booleanWhether to make a copy of X. If false, the input X gets overwritten during fitting.
opts.iterated_power?numberNumber of iterations for the power method. 3 by default. Only used if svd_method equals ‘randomized’.
opts.max_iter?numberMaximum number of iterations.
opts.n_components?numberDimensionality of latent space, the number of components of X that are obtained after transform. If undefined, n_components is set to the number of features.
opts.noise_variance_init?ArrayLikeThe initial guess of the noise variance for each feature. If undefined, it defaults to np.ones(n_features).
opts.random_state?numberOnly used when svd_method equals ‘randomized’. Pass an int for reproducible results across multiple function calls. See Glossary.
opts.rotation?"varimax" | "quartimax"If not undefined, apply the indicated rotation. Currently, varimax and quartimax are implemented. See “The varimax criterion for analytic rotation in factor analysis” H. F. Kaiser, 1958.
opts.svd_method?"randomized" | "lapack"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’.
opts.tol?numberStopping tolerance for log-likelihood increase.

Returns FactorAnalysis

Defined in generated/decomposition/FactorAnalysis.ts:31

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/decomposition/FactorAnalysis.ts:29
_isInitializedbooleanfalsegenerated/decomposition/FactorAnalysis.ts:28
_pyPythonBridgeundefinedgenerated/decomposition/FactorAnalysis.ts:27
idstringundefinedgenerated/decomposition/FactorAnalysis.ts:24
optsanyundefinedgenerated/decomposition/FactorAnalysis.ts:25

Accessors

components_

Get Signature

get components_(): Promise<ArrayLike[]>

Components with maximum variance.

Returns Promise<ArrayLike[]>

Defined in generated/decomposition/FactorAnalysis.ts:518


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

Names of features seen during fit. Defined only when X has feature names that are all strings.

Returns Promise<ArrayLike>

Defined in generated/decomposition/FactorAnalysis.ts:666


loglike_

Get Signature

get loglike_(): Promise<any[]>

The log likelihood at each iteration.

Returns Promise<any[]>

Defined in generated/decomposition/FactorAnalysis.ts:543


mean_

Get Signature

get mean_(): Promise<ArrayLike>

Per-feature empirical mean, estimated from the training set.

Returns Promise<ArrayLike>

Defined in generated/decomposition/FactorAnalysis.ts:618


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/decomposition/FactorAnalysis.ts:641


n_iter_

Get Signature

get n_iter_(): Promise<number>

Number of iterations run.

Returns Promise<number>

Defined in generated/decomposition/FactorAnalysis.ts:593


noise_variance_

Get Signature

get noise_variance_(): Promise<ArrayLike>

The estimated noise variance for each feature.

Returns Promise<ArrayLike>

Defined in generated/decomposition/FactorAnalysis.ts:568


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/decomposition/FactorAnalysis.ts:93

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/decomposition/FactorAnalysis.ts:145


fit()

fit(opts): Promise<any>

Fit the FactorAnalysis model to X using SVD based approach.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training data.
opts.y?anyIgnored parameter.

Returns Promise<any>

Defined in generated/decomposition/FactorAnalysis.ts:162


fit_transform()

fit_transform(opts): Promise<any[]>

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

ParameterTypeDescription
optsobject-
opts.fit_params?anyAdditional fit parameters.
opts.X?ArrayLike[]Input samples.
opts.y?ArrayLikeTarget values (undefined for unsupervised transformations).

Returns Promise<any[]>

Defined in generated/decomposition/FactorAnalysis.ts:201


get_covariance()

get_covariance(opts): Promise<any>

Compute data covariance with the FactorAnalysis model.

cov \= components_.T \* components_ + diag(noise_variance)

Parameters

ParameterTypeDescription
optsobject-
opts.cov?ArrayLike[]Estimated covariance of data.

Returns Promise<any>

Defined in generated/decomposition/FactorAnalysis.ts:245


get_feature_names_out()

get_feature_names_out(opts): Promise<any>

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"\].

Parameters

ParameterTypeDescription
optsobject-
opts.input_features?anyOnly used to validate feature names with the names seen in fit.

Returns Promise<any>

Defined in generated/decomposition/FactorAnalysis.ts:279


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns Promise<any>

Defined in generated/decomposition/FactorAnalysis.ts:315


get_precision()

get_precision(opts): Promise<any>

Compute data precision matrix with the FactorAnalysis model.

Parameters

ParameterTypeDescription
optsobject-
opts.precision?ArrayLike[]Estimated precision of data.

Returns Promise<any>

Defined in generated/decomposition/FactorAnalysis.ts:349


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/decomposition/FactorAnalysis.ts:106


score()

score(opts): Promise<number>

Compute the average log-likelihood of the samples.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]The data.
opts.y?anyIgnored parameter.

Returns Promise<number>

Defined in generated/decomposition/FactorAnalysis.ts:381


score_samples()

score_samples(opts): Promise<ArrayLike>

Compute the log-likelihood of each sample.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]The data.

Returns Promise<ArrayLike>

Defined in generated/decomposition/FactorAnalysis.ts:418


set_output()

set_output(opts): Promise<any>

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters

ParameterTypeDescription
optsobject-
opts.transform?"default" | "pandas" | "polars"Configure output of transform and fit_transform.

Returns Promise<any>

Defined in generated/decomposition/FactorAnalysis.ts:452


transform()

transform(opts): Promise<ArrayLike[]>

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

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training data.

Returns Promise<ArrayLike[]>

Defined in generated/decomposition/FactorAnalysis.ts:486