McrNmf
McrNmf is a Python package for Multivariate Curve Resolution (MCR) using a range of Nonnegative Matrix Factorization (NMF) algorithms. MCR is widely used in chemometrics, for instance, 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 Successive Nonnegative Projection (SNPA) algorithm for generating reliable starting estimates of spectra and concentrations
- Lightweight implementation – written almost entirely in NumPy, with Numba used only to speed up unimodal regression.
For more details, see the documentation.
Installation
With pip:
pip install mcrnmf
Note for macOS Apple Silicon (M4) users: When running the McrNmf package installed via pip, you may encounter runtime numerical warnings (e.g., divide/overflow). To avoid these, please install via conda-forge.
With conda:
conda install -c conda-forge mcrnmf
mcrnmf requires:
- Python ≥ 3.11.9, < 3.14
- NumPy ≥ 1.24, < 2.3
- Numba ≥ 0.61.2
Quick Start
from mcrnmf.datasets import load_rxn_spectra
from mcrnmf import SNPA, MinVol
# load a Raman spectroscopy data (wv × time)
X, wv, t = load_rxn_spectra()
# specify the number of components
rank = 4
# generate initial guess for W and H using SNPA
snpa = SNPA(rank=rank, iter_max=1000)
snpa.fit(X)
Wi = snpa.W # intial guess for W (pure spectra)
Hi = snpa.H # intial guess for H (conc. profiles)
mvol = MinVol(rank=rank,
constraint_kind=1,
unimodality={"H": True},
iter_max=2000,
tol=1e-4)
# fit the Minimum Volume NMF model
mvol.fit(X=X, Wi=Wi, Hi=Hi)
# access the decomposed factors
W = mvol.W
H = mvol.H
# access relative reconstruction error at each iter.
rel_recon_err = mvol.rel_reconstruction_error_ls
More worked examples can be found in the Usage section of the documentation.
Citation
If you use McrNmf in your work, please consider citing the following preprint:
Vasudevan SA, Kohlbrenner R, Ritschel N, Vent-Schmidt T. Beyond Classical MCR-ALS—Minimum Volume NMF and Strategic Sampling for Robust Reaction Monitoring. ChemRxiv. 2025; doi:10.26434/chemrxiv-2025-qs5g4
License
MIT – see LICENSE.
Metadata
Release files for mcrnmf 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcrnmf-0.1.2.tar.gz | 3.8 MB | Without provenance | Details for mcrnmf-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcrnmf-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for mcrnmf-0.1.2-py3-none-any.whl |
Total release size: 7.5 MB
Release files / mcrnmf-0.1.2.tar.gz
| Download URL | mcrnmf-0.1.2.tar.gz |
|---|---|
| Size | 3.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33dc5bef65d6b400c67547a7e5565088313edcb5c87d039f43619da896408766
|
|
BLAKE2b-256 checksum How to use checksums |
afa638a84dfab412b9ed9d9898b8ef28f4709d17575f4f69e42c52d99620ba79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.8
|
Release files / mcrnmf-0.1.2-py3-none-any.whl
| Download URL | mcrnmf-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2cf360fb76377de7245019aaf980ececf1581dc159ba20ed04c82a1256b1f351
|
|
BLAKE2b-256 checksum How to use checksums |
7645b3bd2cb74d9d29bbe43085448a8bf1a42f868f7ffdb519291dc0a915a887
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.8
|
Security for mcrnmf 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.