McrNmf Documentation#
Welcome to the documentation for McrNmf, a Python package for Multivariate Curve Resolution (MCR) using different Nonnegative Matrix Factorization (NMF) algorithms. The source code is hosted on GitHub: siddarthVasudevan/mcrnmf
MCR is widely used in chemometrics to decompose mixture spectra into their pure component spectra and associated concentration profiles.
Key Features#
Multiple solvers – unified interface for three NMF variants: classic Alternating Least Squares (
FroALS
), Fast Projected Gradient (FroFPGM
), and Minimum-Volume formulation (MinVol
)Built-in constraints – supports closure, normalization, equality, and per-component unimodality constraints
Robust initialisation – includes
SNPA
algorithm for generating reliable starting estimates of spectra and concentrationsLightweight implementation – written almost entirely in NumPy, with Numba used only to speed up unimodal regression
Installation#
conda install -c conda-forge mcrnmf
Basic Usage#
from mcrnmf import MinVol, SNPA
from mcrnmf.datasets import load_rxn_spectra
# Load example data
X, wv, time = load_rxn_spectra()
# Get initial guess using SNPA
snpa = SNPA(rank=4)
snpa.fit(X)
Wi = snpa.W.copy()
Hi = snpa.H.copy()
# Initialize MinVol with SNPA results and apply constraints
model = MinVol(rank=4, constraint_kind=1)
model.fit(X=X, Wi=Wi, Hi=Hi)
# Access results
W = model.W # Pure component spectra
H = model.H # Concentration profiles
Next Steps#
See the Usage Guide page for worked examples
Browse the API Reference for full API documentation
Check the Installation page for detailed setup info