Documentation
Classes
MiniBatchSparsePCA

MiniBatchSparsePCA

Mini-batch Sparse Principal Components Analysis.

Finds the set of sparse components that can optimally reconstruct the data. The amount of sparseness is controllable by the coefficient of the L1 penalty, given by the parameter alpha.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new MiniBatchSparsePCA(opts?: object): MiniBatchSparsePCA;

Parameters

NameTypeDescription
opts?object-
opts.alpha?numberSparsity controlling parameter. Higher values lead to sparser components. Default Value 1
opts.batch_size?numberThe number of features to take in each mini batch. Default Value 3
opts.callback?anyCallable that gets invoked every five iterations.
opts.max_iter?numberMaximum number of iterations over the complete dataset before stopping independently of any early stopping criterion heuristics. If max\_iter is not undefined, n\_iter is ignored.
opts.max_no_improvement?numberControl early stopping based on the consecutive number of mini batches that does not yield an improvement on the smoothed cost function. Used only if max\_iter is not undefined. To disable convergence detection based on cost function, set max\_no\_improvement to undefined. Default Value 10
opts.method?"cd" | "lars"Method to be used for optimization. lars: uses the least angle regression method to solve the lasso problem (linear_model.lars_path) cd: uses the coordinate descent method to compute the Lasso solution (linear_model.Lasso). Lars will be faster if the estimated components are sparse. Default Value 'lars'
opts.n_components?numberNumber of sparse atoms to extract. If undefined, then n\_components is set to n\_features.
opts.n_iter?numberNumber of iterations to perform for each mini batch. Default Value 100
opts.n_jobs?numberNumber of parallel jobs to run. undefined means 1 unless in a joblib.parallel\_backend (opens in a new tab) context. \-1 means using all processors. See Glossary for more details.
opts.random_state?numberUsed for random shuffling when shuffle is set to true, during online dictionary learning. Pass an int for reproducible results across multiple function calls. See Glossary.
opts.ridge_alpha?numberAmount of ridge shrinkage to apply in order to improve conditioning when calling the transform method. Default Value 0.01
opts.shuffle?booleanWhether to shuffle the data before splitting it in batches. Default Value true
opts.tol?numberControl early stopping based on the norm of the differences in the dictionary between 2 steps. Used only if max\_iter is not undefined. To disable early stopping based on changes in the dictionary, set tol to 0.0. Default Value 0.001
opts.verbose?number | booleanControls the verbosity; the higher, the more messages. Defaults to 0. Default Value false

Returns

MiniBatchSparsePCA

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:25 (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/MiniBatchSparsePCA.ts:191 (opens in a new tab)

fit()

Fit the model from data in X.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Training vector, where n\_samples is the number of samples and n\_features is the number of features.
opts.y?anyNot used, present here for API consistency by convention.

Returns

Promise<any>

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:208 (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/MiniBatchSparsePCA.ts:250 (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/MiniBatchSparsePCA.ts:303 (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/MiniBatchSparsePCA.ts:343 (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/MiniBatchSparsePCA.ts:135 (opens in a new tab)

inverse_transform()

Transform data from the latent space to the original space.

This inversion is an approximation due to the loss of information induced by the forward decomposition.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Data in the latent space.

Returns

Promise<ArrayLike[]>

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:383 (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/MiniBatchSparsePCA.ts:423 (opens in a new tab)

transform()

Least Squares projection of the data onto the sparse components.

To avoid instability issues in case the system is under-determined, regularization can be applied (Ridge regression) via the ridge\_alpha parameter.

Note that Sparse PCA components orthogonality is not enforced as in PCA hence one cannot use a simple linear projection.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Test data to be transformed, must have the same number of features as the data used to train the model.

Returns

Promise<ArrayLike[]>

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:462 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:21 (opens in a new tab)

id

string

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:18 (opens in a new tab)

opts

any

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:19 (opens in a new tab)

Accessors

components_

Sparse components extracted from the data.

Signature

components_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:497 (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/MiniBatchSparsePCA.ts:632 (opens in a new tab)

mean_

Per-feature empirical mean, estimated from the training set. Equal to X.mean(axis=0).

Signature

mean_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:578 (opens in a new tab)

n_components_

Estimated number of components.

Signature

n_components_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:524 (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/MiniBatchSparsePCA.ts:605 (opens in a new tab)

n_iter_

Number of iterations run.

Signature

n_iter_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:551 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:122 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/decomposition/MiniBatchSparsePCA.ts:126 (opens in a new tab)