MiniBatchNMF
Mini-Batch Non-Negative Matrix Factorization (NMF).
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new MiniBatchNMF(opts?: object): MiniBatchNMF;
Parameters
Name | Type | Description |
---|---|---|
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? | number | Constant that multiplies the regularization terms of W . Set it to zero (default) to have no regularization on W . Default Value 0 |
opts.batch_size? | number | Number 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? | number | Amount 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? | boolean | Whether 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? | number | Maximum 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? | number | The 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? | number | Maximum number of iterations over the complete dataset before timing out. Default Value 200 |
opts.max_no_improvement? | number | Control 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? | number | Number of components, if n\_components is not set all features are kept. |
opts.random_state? | number | Used 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? | number | Control 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? | number | Maximum number of iterations when solving for W at transform time. If undefined , it defaults to max\_iter . |
opts.verbose? | boolean | Whether to be verbose. Default Value false |
Returns
Defined in: generated/decomposition/MiniBatchNMF.ts:21 (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:520 (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:666 (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:545 (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:641 (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:595 (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:618 (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
Name | Type |
---|---|
pythonBridge | PythonBridge |
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:570 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Training vector, where n\_samples is the number of samples and n\_features is the number of features. |
opts.params? | any | Parameters (keyword arguments) and values passed to the fit_transform instance. |
opts.y? | any | Not 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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.H? | ArrayLike [] | If init='custom' , it is used as initial guess for the solution. |
opts.W? | ArrayLike [] | If init='custom' , it is used as initial guess for the solution. |
opts.X? | ArrayLike | Data matrix to be decomposed. |
opts.y? | any | Not 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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.input_features? | any | Only 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)
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
Name | Type |
---|---|
py | PythonBridge |
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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.W? | ArrayLike | Transformed data matrix. |
Returns
Promise
<ArrayLike
>
Defined in: generated/decomposition/MiniBatchNMF.ts:359 (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
Name | Type | Description |
---|---|---|
opts | object | - |
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? | ArrayLike | Data matrix to be decomposed. |
opts.y? | any | Not used, present here for API consistency by convention. |
Returns
Promise
<any
>
Defined in: generated/decomposition/MiniBatchNMF.ts:398 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.transform? | "default" | "pandas" | Configure output of transform and fit\_transform . |
Returns
Promise
<any
>
Defined in: generated/decomposition/MiniBatchNMF.ts:454 (opens in a new tab)
transform()
Transform the data X according to the fitted MiniBatchNMF model.
Signature
transform(opts: object): Promise<ArrayLike[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Data matrix to be transformed by the model. |
Returns
Promise
<ArrayLike
[]>
Defined in: generated/decomposition/MiniBatchNMF.ts:487 (opens in a new tab)