hyperspy.learn.onmf module

class hyperspy.learn.onmf.ONMF(rank, lambda1=1.0, kappa=1.0, store_r=False, robust=False)

Bases: object

This class performs Online Robust NMF with missing or corrupted data.

fit()

learn factors from the given data

project()

project the learnt factors on the given data

finish()

return the learnt factors and loadings

Notes

The ONMF code is based on a transcription of the OPGD algorithm MATLAB code obtained from the authors of the following research paper:

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.

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

Creates Online Robust NMF instance that can learn a representation

Parameters
  • rank (int) – The rank of the representation (number of components/factors)

  • lambda1 (float) – Nuclear norm regularization parameter.

  • kappa (float) – Sparse error regularization parameter.

  • store_r (bool) – If True, stores the sparse error matrix, False by default.

  • robust (bool) – If True, the original OPGD implementation is used for corruption/outlier regularization, otherwise L2-norm. False by default.

finish()

Return the learnt factors and loadings.

fit(X, batch_size=None)

Learn NMF components from the data.

Parameters
  • X ({numpy.ndarray, iterator}) – [nsamplex x nfeatures] matrix of observations or an iterator that yields samples, each with nfeatures elements.

  • batch_size ({None, int}) – If not None, learn the data in batches, each of batch_size samples or less.

project(X, return_R=False)

Project the learnt components on the data.

Parameters
  • X ({numpy.ndarray, iterator}) – [nsamplex x nfeatures] matrix of observations or an iterator that yields samples, each with nfeatures elements.

  • return_R (bool) – If True, returns the sparse error matrix as well. Otherwise only the weights (loadings)

hyperspy.learn.onmf.onmf(X, rank, lambda1=1, kappa=1, store_r=False, project=False, robust=False)