hyperspy_ml_algorithms.ORNMF#

class hyperspy_ml_algorithms.ORNMF(n_components, store_error=False, lambda1=1.0, kappa=1.0, method='PGD', subspace_learning_rate=1.0, subspace_momentum=0.5, random_state=None)#

Bases: object

Online Robust NMF with missing or corrupted data.

The ORNMF code is based on a transcription of the online proximal gradient descent (PGD) algorithm MATLAB code obtained from the authors of [Zhao2016]. It has been updated to also include L2-normalization cost function that is able to deal with sparse corruptions and/or outliers slightly faster (please see ORPCA implementation for details). A further modification has been made to allow for a changing subspace W, where X ~= W H^T + E in the ORNMF framework.

Read more in the User Guide.

Parameters:
n_componentsint

The rank of the representation (number of components).

store_errorbool, default False

If True, stores the sparse error matrix.

lambda1float, default 1.0

Nuclear norm regularization parameter.

kappafloat, default 1.0

Step-size for projection solver.

method{'PGD', 'RobustPGD', 'MomentumSGD'}, default 'PGD'
  • 'PGD' - Proximal gradient descent

  • 'RobustPGD' - Robust proximal gradient descent

  • 'MomentumSGD' - Stochastic gradient descent with momentum

subspace_learning_ratefloat, default 1.0

Learning rate for the 'MomentumSGD' method. Should be a float > 0.0.

subspace_momentumfloat, default 0.5

Momentum parameter for 'MomentumSGD' method, should be a float between 0 and 1.

random_stateNone or int or RandomState, default None

Used to initialize the subspace on the first iteration. See numpy.random.default_rng() for more information.

Attributes:
components_ndarray, shape (n_components, n_features)

Learned dictionary, shape (n_components, n_features).

scores_ndarray, shape (n_samples, n_components)

Learned scores, shape (n_samples, n_components).

References

[Zhao2016]

Zhao, Renbo, and Vincent YF Tan. “Online nonnegative matrix factorization with outliers.” Acoustics, Speech and Signal Processing (ICASSP), 2016 IEEE International Conference on. IEEE, 2016.

__init__(n_components, store_error=False, lambda1=1.0, kappa=1.0, method='PGD', subspace_learning_rate=1.0, subspace_momentum=0.5, random_state=None)#

Methods

__init__(n_components[, store_error, ...])

fit(X[, y])

Learn NMF components from the data.

fit_transform(X[, y])

Fit to X then project it in one call.

partial_fit(X[, batch_size])

Process one batch of data.

transform(X)

Project X onto the learned dictionary.

Attributes

components_

Learned dictionary, shape (n_components, n_features).

scores_

Learned scores, shape (n_samples, n_components).