Class: MiniBatchNMF

Mini-Batch Non-Negative Matrix Factorization (NMF).

Python Reference

Constructors

new MiniBatchNMF()

new MiniBatchNMF(opts?): MiniBatchNMF

Parameters

ParameterTypeDescription
opts?object-
opts.alpha_H?number | "same"Constant that multiplies the regularization terms of H. Set it to zero to have no regularization on H. If “same” (default), it takes the same value as alpha_W.
opts.alpha_W?numberConstant that multiplies the regularization terms of W. Set it to zero (default) to have no regularization on W.
opts.batch_size?numberNumber of samples in each mini-batch. Large batch sizes give better long-term convergence at the cost of a slower start.
opts.beta_loss?number | "frobenius" | "kullback-leibler" | "itakura-saito"Beta divergence to be minimized, measuring the distance between X and the dot product WH. Note that values different from ‘frobenius’ (or 2) and ‘kullback-leibler’ (or 1) lead to significantly slower fits. Note that for beta_loss <= 0 (or ‘itakura-saito’), the input matrix X cannot contain zeros.
opts.forget_factor?numberAmount of rescaling of past information. Its value could be 1 with finite datasets. Choosing values < 1 is recommended with online learning as more recent batches will weight more than past batches.
opts.fresh_restarts?booleanWhether to completely solve for W at each step. Doing fresh restarts will likely lead to a better solution for a same number of iterations but it is much slower.
opts.fresh_restarts_max_iter?numberMaximum number of iterations when solving for W at each step. Only used when doing fresh restarts. These iterations may be stopped early based on a small change of W controlled by tol.
opts.init?"random" | "nndsvd" | "nndsvda" | "nndsvdar" | "custom"Method used to initialize the procedure. Valid options:
opts.l1_ratio?numberThe regularization mixing parameter, with 0 <= l1_ratio <= 1. For l1_ratio = 0 the penalty is an elementwise L2 penalty (aka Frobenius Norm). For l1_ratio = 1 it is an elementwise L1 penalty. For 0 < l1_ratio < 1, the penalty is a combination of L1 and L2.
opts.max_iter?numberMaximum number of iterations over the complete dataset before timing out.
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. To disable convergence detection based on cost function, set max_no_improvement to undefined.
opts.n_components?number | "auto"Number of components, if n_components is not set all features are kept. If n_components='auto', the number of components is automatically inferred from W or H shapes.
opts.random_state?numberUsed for initialisation (when init == ‘nndsvdar’ or ‘random’), and in Coordinate Descent. Pass an int for reproducible results across multiple function calls. See Glossary.
opts.tol?numberControl early stopping based on the norm of the differences in H between 2 steps. To disable early stopping based on changes in H, set tol to 0.0.
opts.transform_max_iter?numberMaximum number of iterations when solving for W at transform time. If undefined, it defaults to max_iter.
opts.verbose?booleanWhether to be verbose.

Returns MiniBatchNMF

Defined in generated/decomposition/MiniBatchNMF.ts:21

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/decomposition/MiniBatchNMF.ts:19
_isInitializedbooleanfalsegenerated/decomposition/MiniBatchNMF.ts:18
_pyPythonBridgeundefinedgenerated/decomposition/MiniBatchNMF.ts:17
idstringundefinedgenerated/decomposition/MiniBatchNMF.ts:14
optsanyundefinedgenerated/decomposition/MiniBatchNMF.ts:15

Accessors

components_

Get Signature

get components_(): Promise<ArrayLike[]>

Factorization matrix, sometimes called ‘dictionary’.

Returns Promise<ArrayLike[]>

Defined in generated/decomposition/MiniBatchNMF.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/MiniBatchNMF.ts:664


n_components_

Get Signature

get n_components_(): Promise<number>

The number of components. It is same as the n_components parameter if it was given. Otherwise, it will be same as the number of features.

Returns Promise<number>

Defined in generated/decomposition/MiniBatchNMF.ts:543


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/decomposition/MiniBatchNMF.ts:639


n_iter_

Get Signature

get n_iter_(): Promise<number>

Actual number of started iterations over the whole dataset.

Returns Promise<number>

Defined in generated/decomposition/MiniBatchNMF.ts:593


n_steps_

Get Signature

get n_steps_(): Promise<number>

Number of mini-batches processed.

Returns Promise<number>

Defined in generated/decomposition/MiniBatchNMF.ts:616


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/decomposition/MiniBatchNMF.ts:130


reconstruction_err_

Get Signature

get reconstruction_err_(): Promise<number>

Frobenius norm of the matrix difference, or beta-divergence, between the training data X and the reconstructed data WH from the fitted model.

Returns Promise<number>

Defined in generated/decomposition/MiniBatchNMF.ts:568

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/MiniBatchNMF.ts:182


fit()

fit(opts): Promise<any>

Learn a NMF model for the data X.

Parameters

ParameterTypeDescription
optsobject-
opts.params?anyParameters (keyword arguments) and values passed to the fit_transform instance.
opts.X?ArrayLikeTraining vector, where n_samples is the number of samples and n_features is the number of features.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<any>

Defined in generated/decomposition/MiniBatchNMF.ts:199


fit_transform()

fit_transform(opts): Promise<ArrayLike[]>

Learn a NMF model for the data X and returns the transformed data.

This is more efficient than calling fit followed by transform.

Parameters

ParameterTypeDescription
optsobject-
opts.H?ArrayLike[]If init='custom', it is used as initial guess for the solution. If undefined, uses the initialisation method specified in init.
opts.W?ArrayLike[]If init='custom', it is used as initial guess for the solution. If undefined, uses the initialisation method specified in init.
opts.X?ArrayLikeData matrix to be decomposed.
opts.y?anyNot used, present here for API consistency by convention.

Returns Promise<ArrayLike[]>

Defined in generated/decomposition/MiniBatchNMF.ts:243


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/MiniBatchNMF.ts:292


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/MiniBatchNMF.ts:328


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/MiniBatchNMF.ts:143


inverse_transform()

inverse_transform(opts): Promise<ArrayLike[]>

Transform data back to its original space.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeTransformed data matrix.
opts.Xt?ArrayLikeTransformed data matrix.

Returns Promise<ArrayLike[]>

Defined in generated/decomposition/MiniBatchNMF.ts:362


partial_fit()

partial_fit(opts): Promise<any>

Update the model using the data in X as a mini-batch.

This method is expected to be called several times consecutively on different chunks of a dataset so as to implement out-of-core or online learning.

This is especially useful when the whole dataset is too big to fit in memory at once (see Strategies to scale computationally: bigger data).

Parameters

ParameterTypeDescription
optsobject-
opts.H?ArrayLike[]If init='custom', it is used as initial guess for the solution. Only used for the first call to partial_fit.
opts.W?ArrayLike[]If init='custom', it is used as initial guess for the solution. Only used for the first call to partial_fit.
opts.X?ArrayLikeData matrix to be decomposed.
opts.y?anyNot used, present here for API consistency by convention.

Returns Promise<any>

Defined in generated/decomposition/MiniBatchNMF.ts:405


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/MiniBatchNMF.ts:454


transform()

transform(opts): Promise<ArrayLike[]>

Transform the data X according to the fitted MiniBatchNMF model.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeData matrix to be transformed by the model.

Returns Promise<ArrayLike[]>

Defined in generated/decomposition/MiniBatchNMF.ts:486