NMF (libnmfd.core.nmf)

libnmfd.core.nmf.nmf(V, num_comp: int, cost_func: str = 'KLDiv', num_iter: int = 30, init_W: ndarray | None = None, init_H: ndarray | None = None, fix_W: bool = False) Tuple[ndarray, ndarray, List][source]

Given a non-negative matrix V, find non-negative templates W and activations H that approximate V.

References

[1] Lee, DD & Seung, HS. “Algorithms for Non-negative Matrix Factorization”

[2] Andrzej Cichocki, Rafal Zdunek, Anh Huy Phan, and Shunichi Amari Nonnegative Matrix and Tensor Factorizations” Applications to Exploratory Multi-Way Data Analysis and Blind Source Separation” John Wiley and Sons, 2009.

Parameters:
  • V (np.ndarray) – K x M non-negative matrix to be factorized

  • num_comp (int) – The rank of the approximation

  • cost_func (str, default=KLDiv) –

    Cost function used for the optimization, currently supported are:

    ‘EucDist’ for Euclidean Distance ‘KLDiv’ for Kullback Leibler Divergence ‘ISDiv’ for Itakura Saito Divergence

  • num_iter (int) – Number of iterations the algorithm will run.

  • init_W (np.ndarray, default=None) – An initial estimate for the templates

  • init_H (np.ndarray, default=None) – An initial estimate for the activations

  • fix_W (bool, default=False) – Set True if templates W should be constant during the update process.

Returns:
  • W (np.ndarray) – K x R non-negative templates

  • H (np.ndarray) – R x M non-negative activations

  • nmf_V (list) – Approximated component matrices