Documentation
Classes
FactorAnalysis

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 (opens in a new tab)

Constructors

constructor()

Signature

new FactorAnalysis(opts?: object): FactorAnalysis;

Parameters

NameTypeDescription
opts?object-
opts.copy?booleanWhether to make a copy of X. If false, the input X gets overwritten during fitting. Default Value true
opts.iterated_power?numberNumber of iterations for the power method. 3 by default. Only used if svd\_method equals ‘randomized’. Default Value 3
opts.max_iter?numberMaximum number of iterations. Default Value 1000
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. Default Value 0
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” (opens in a new tab) 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’. Default Value 'randomized'
opts.tol?numberStopping tolerance for log-likelihood increase. Default Value 0.01

Returns

FactorAnalysis

Defined in: generated/decomposition/FactorAnalysis.ts:31 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

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

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/decomposition/FactorAnalysis.ts:160 (opens in a new tab)

fit()

Fit the FactorAnalysis model to X using SVD based approach.

Signature

fit(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/decomposition/FactorAnalysis.ts:177 (opens in a new tab)

fit_transform()

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit\_params and returns a transformed version of X.

Signature

fit_transform(opts: object): Promise<any[]>;

Parameters

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

Returns

Promise<any[]>

Defined in: generated/decomposition/FactorAnalysis.ts:217 (opens in a new tab)

get_covariance()

Compute data covariance with the FactorAnalysis model.

cov \= components\_.T \* components\_ + diag(noise\_variance)

Signature

get_covariance(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/decomposition/FactorAnalysis.ts:266 (opens in a new tab)

get_feature_names_out()

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

Signature

get_feature_names_out(opts: object): Promise<any>;

Parameters

NameTypeDescription
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:301 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/decomposition/FactorAnalysis.ts:339 (opens in a new tab)

get_precision()

Compute data precision matrix with the FactorAnalysis model.

Signature

get_precision(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/decomposition/FactorAnalysis.ts:374 (opens in a new tab)

init()

Initializes the underlying Python resources.

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

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/decomposition/FactorAnalysis.ts:106 (opens in a new tab)

score()

Compute the average log-likelihood of the samples.

Signature

score(opts: object): Promise<number>;

Parameters

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

Returns

Promise<number>

Defined in: generated/decomposition/FactorAnalysis.ts:408 (opens in a new tab)

score_samples()

Compute the log-likelihood of each sample.

Signature

score_samples(opts: object): Promise<ArrayLike>;

Parameters

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

Returns

Promise<ArrayLike>

Defined in: generated/decomposition/FactorAnalysis.ts:446 (opens in a new tab)

set_output()

Set output container.

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

Signature

set_output(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.transform?"default" | "pandas"Configure output of transform and fit\_transform.

Returns

Promise<any>

Defined in: generated/decomposition/FactorAnalysis.ts:481 (opens in a new tab)

transform()

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).

Signature

transform(opts: object): Promise<ArrayLike[]>;

Parameters

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

Returns

Promise<ArrayLike[]>

Defined in: generated/decomposition/FactorAnalysis.ts:516 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/decomposition/FactorAnalysis.ts:29 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/decomposition/FactorAnalysis.ts:28 (opens in a new tab)

_py

PythonBridge

Defined in: generated/decomposition/FactorAnalysis.ts:27 (opens in a new tab)

id

string

Defined in: generated/decomposition/FactorAnalysis.ts:24 (opens in a new tab)

opts

any

Defined in: generated/decomposition/FactorAnalysis.ts:25 (opens in a new tab)

Accessors

components_

Components with maximum variance.

Signature

components_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/decomposition/FactorAnalysis.ts:549 (opens in a new tab)

feature_names_in_

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

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/decomposition/FactorAnalysis.ts:697 (opens in a new tab)

loglike_

The log likelihood at each iteration.

Signature

loglike_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/decomposition/FactorAnalysis.ts:574 (opens in a new tab)

mean_

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

Signature

mean_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/decomposition/FactorAnalysis.ts:649 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/decomposition/FactorAnalysis.ts:672 (opens in a new tab)

n_iter_

Number of iterations run.

Signature

n_iter_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/decomposition/FactorAnalysis.ts:624 (opens in a new tab)

noise_variance_

The estimated noise variance for each feature.

Signature

noise_variance_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/decomposition/FactorAnalysis.ts:599 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/decomposition/FactorAnalysis.ts:93 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/decomposition/FactorAnalysis.ts:97 (opens in a new tab)