darfix.decomposition.nmf.NMF#

class darfix.decomposition.nmf.NMF(data, num_components=None, indices=None, epsilon=1e-07)[source]#

Bases: Base

Non-Negative Matrix Factorization.

Find two non-negative matrices whose product approximates the non-negative matrix data.

property data#
fit_transform(H=None, W=None, max_iter=1000, compute_w=True, compute_h=True, vstep=100, hstep=1000, error_step=None)[source]#

Find the two non-negative matrices (H, W) using Lee and Seung’s multiplicative update rule (https://proceedings.neurips.cc/paper/2000/file/f9d1152547c0bde01830b7e8bd60024c-Paper.pdf). The images are loaded from disk in chunks.

Parameters:
  • H (array_like, shape (n_components, n_features), optional) – If not None, used as initial guess for the solution.

  • W (array_like, shape (n_samples, n_components)) – If not None, used as initial guess for the solution.

  • max_iter (int, optional) – Maximum number of iterations before timing out, defaults to 200

  • compute_w (bool, optional) – If False, W is not computed.

  • compute_h (bool, optional) – If False, H is not computes.

  • vstep (int, optional) – vertical size of the chunks to take from data. When updating W, vstep images are retrieved from disk per iteration, defaults to 100.

  • hstep (int, optional) – horizontal size of the chunks to take from fata. When updating H, hstep pixels are retrieved from disk per iteration, defaults to 1000.

  • error_step (Union[None,int], optional) – If None, error is not computed, else compute error for every error_step iterations.

frobenius_norm(chunks=200)#

Frobenius norm (||data - WH||) of a data matrix and a low rank approximation given by WH. Minimizing the Fnorm is the most common optimization criterion for matrix factorization methods. Returns: ——- frobenius norm: F = ||data - WH||

property indices#
property num_components#
property num_features#
property num_samples#
squared_frobenius_norm(chunks=200)#

Frobenius norm (||data - WH||) of a data matrix and a low rank approximation given by WH. Minimizing the Fnorm is the most common optimization criterion for matrix factorization methods. Returns: ——- frobenius norm: F = ||data - WH||