SNPA#

class mcrnmf.models.SNPA(rank, iter_max=500, tol=1e-06)[source]#

Successive Nonnegative Projection Algorithm (SNPA) for NMF initialization.

The algorithm sequentially selects columns from \(X\) with maximum residual norm after projecting onto the convex cone generated by previously selected columns, providing a robust initialization for \(W\) which can be used by other NMF models. The corresponding \(H\) matrix is then computed by minimizing \(||X - WH||_F^2\) subject to nonnegativity and simplex constraints on \(H\).

Parameters:
rankint

The number of components to extract.

iter_maxint, default=500

Maximum number of iterations for updating \(H\) after extraction of \(W\).

tolfloat, default=1e-6

Tolerance for early stopping. The algorithm stops extracting basis compnents when:

\[\dfrac{||X - WH||_F}{||X||_{F}} \leq \textrm{tol}\]

where \(||\cdot||_{F}\) is the Frobenius norm.

Examples

>>> from mcrnmf.models import SNPA
>>> from mcrnmf.datasets import load_rxn_spectra
>>>
>>> # load the example dataset from mcrnmf
>>> X, wv, time  = load_rxn_spectra()
>>>
>>> # create an instance of SNPA and fit to the data
>>> snpa = SNPA(rank=4)
>>> snpa.fit(X)
>>> Wi = snpa.W  # Estimate for W
>>> Hi = snpa.H  # Estimate for H
>>> selected_indices = model.col_indices_ls
fit(X)[source]#

Fit the SNPA model to the provided data.

Parameters:
Xndarray of shape (n_features, n_samples)

Data array to be factorized.

Warns:
UserWarning

If the desired rank is not reached due to early convergence. If this happens try specifying a lower value for tol.

property H#

The coefficient matrix derived from \(W\).

Returns:
ndarray of shape (rank, n_samples)

The coefficient matrix derived from \(W\).

property W#

The basis matrix containing selected columns from \(X\).

Returns:
ndarray of shape (n_features, rank)

The basis matrix containing selected columns from \(X\).

property col_indices_ls#

The indices of columns selected from \(X\) for \(W\).

Returns:
list of int

The indices of columns selected from \(X\) for \(W\) after fitting the model.