Documentation
Classes
MiniBatchNMF

MiniBatchNMF

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

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new MiniBatchNMF(opts?: object): MiniBatchNMF;

Parameters

NameTypeDescription
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. Default Value 'same'
opts.alpha_W?numberConstant that multiplies the regularization terms of W. Set it to zero (default) to have no regularization on W. Default Value 0
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. Default Value 1024
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. Default Value 'frobenius'
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. Default Value 0.7
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. Default Value false
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. Default Value 30
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. Default Value 0
opts.max_iter?numberMaximum number of iterations over the complete dataset before timing out. Default Value 200
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. Default Value 10
opts.n_components?numberNumber of components, if n\_components is not set all features are kept.
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. Default Value 0.0001
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. Default Value false

Returns

MiniBatchNMF

Defined in: generated/decomposition/MiniBatchNMF.ts:21 (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/MiniBatchNMF.ts:203 (opens in a new tab)

fit()

Learn a NMF model for the data X.

Signature

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

Parameters

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

Returns

Promise<any>

Defined in: generated/decomposition/MiniBatchNMF.ts:220 (opens in a new tab)

fit_transform()

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

This is more efficient than calling fit followed by transform.

Signature

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

Parameters

NameTypeDescription
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:267 (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/MiniBatchNMF.ts:323 (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/MiniBatchNMF.ts:361 (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/MiniBatchNMF.ts:143 (opens in a new tab)

inverse_transform()

Transform data back to its original space.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.W?anyUse Xt instead.
opts.Xt?ArrayLikeTransformed data matrix.

Returns

Promise<ArrayLike>

Defined in: generated/decomposition/MiniBatchNMF.ts:396 (opens in a new tab)

partial_fit()

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

Signature

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

Parameters

NameTypeDescription
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:440 (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/MiniBatchNMF.ts:496 (opens in a new tab)

set_partial_fit_request()

Request metadata passed to the partial\_fit method.

Note that this method is only relevant if enable\_metadata\_routing=True (see sklearn.set\_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.H?string | booleanMetadata routing for H parameter in partial\_fit.
opts.W?string | booleanMetadata routing for W parameter in partial\_fit.

Returns

Promise<any>

Defined in: generated/decomposition/MiniBatchNMF.ts:533 (opens in a new tab)

transform()

Transform the data X according to the fitted MiniBatchNMF model.

Signature

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

Parameters

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

Returns

Promise<ArrayLike[]>

Defined in: generated/decomposition/MiniBatchNMF.ts:573 (opens in a new tab)

Properties

_isDisposed

boolean = false

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

_isInitialized

boolean = false

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

_py

PythonBridge

Defined in: generated/decomposition/MiniBatchNMF.ts:17 (opens in a new tab)

id

string

Defined in: generated/decomposition/MiniBatchNMF.ts:14 (opens in a new tab)

opts

any

Defined in: generated/decomposition/MiniBatchNMF.ts:15 (opens in a new tab)

Accessors

components_

Factorization matrix, sometimes called ‘dictionary’.

Signature

components_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/decomposition/MiniBatchNMF.ts:606 (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/MiniBatchNMF.ts:752 (opens in a new tab)

n_components_

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.

Signature

n_components_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/decomposition/MiniBatchNMF.ts:631 (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/MiniBatchNMF.ts:727 (opens in a new tab)

n_iter_

Actual number of started iterations over the whole dataset.

Signature

n_iter_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/decomposition/MiniBatchNMF.ts:681 (opens in a new tab)

n_steps_

Number of mini-batches processed.

Signature

n_steps_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/decomposition/MiniBatchNMF.ts:704 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/decomposition/MiniBatchNMF.ts:130 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/decomposition/MiniBatchNMF.ts:134 (opens in a new tab)

reconstruction_err_

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

Signature

reconstruction_err_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/decomposition/MiniBatchNMF.ts:656 (opens in a new tab)