Skip to main content

geom-nmf

PyPI Tests Python Versions License

Geometric non-negative matrix factorization (GeomNMF) via maximum-volume simplex fitting.

GeomNMF assumes a nonnegative data matrix follows a simplex mixing model

Y ≈ W H,   W ≥ 0,   H ≥ 0,   H 1 = 1

and estimates the source profiles H (endmembers) as the vertices of the maximum-volume (K−1)-simplex inscribed in the convex hull of the row-normalized data. It then recovers the mixing weights W and a source attribution matrix Φ giving the share of each feature attributable to each source. Typical applications include source apportionment of multi-pollutant air quality data and spectral unmixing.

Getting Started

Installation

pip install geom-nmf

With optional plotting (matplotlib) and progress-bar (tqdm) support:

pip install "geom-nmf[all]"
Extra Enables
plot barplot_Phi (installs matplotlib)
progress tqdm progress bar for the max-volume search (verbose=True)
all both

To get the latest development version from GitHub instead:

pip install "geom-nmf[all] @ git+https://github.com/jinbora0720/geom-nmf.git"

Quick example

import numpy as np
from geom_nmf import GeomNMF, barplot_Phi, permute_to_reference

rng = np.random.default_rng(0)
K, J, N = 3, 6, 1000
H_true = rng.dirichlet(np.ones(J), size=K)          # (K, J) source profiles
W_true = rng.dirichlet(0.5 * np.ones(K), size=N)    # (N, K) mixing proportions
Y = rng.lognormal(size=(N, 1)) * (W_true @ H_true)  # (N, J) nonnegative data

result = GeomNMF(Y, K=3)

result.H_star      # (K, J) estimated source profiles, rows sum to 1
result.W_tilde     # (N, K) source contributions on the original scale of Y
result.mu_tilde    # (K,)   mean contribution per source
result.Phi         # (K, J) share of each feature attributable to each source
result.fit_diagnostics["intrinsic_rank"]   # should be K - 1 for noise-free data

# sources are identified up to permutation; align with a reference if you have one
H_hat, mu_hat, Phi_hat, order = permute_to_reference(H_true, result.H_star, result.mu_tilde, result.Phi)

barplot_Phi(Phi_hat, feature_labels=["PM1", "PM2.5", "PM10", "CO", "NO2", "O3"])

Y can be a NumPy array, a pandas DataFrame, or any 2-D array-like. A runnable version is in examples/quickstart.py.

Public API

Function / class Purpose
GeomNMF Full pipeline; returns a GeomNMFResult named tuple
nfindr Standalone N-FINDR endmember extraction
log_simplex_volume Log-volume of the simplex spanned by K points
estimate_weights Recover simplex weights W given Y and H
compute_Phi Source attribution matrix from mean weights and H
permute_to_reference Align estimated sources to a reference ordering (Hungarian)
barplot_Phi Grouped bar plot of Φ, optionally with bootstrap error bars

Choosing options

  • candidate_method="exact" (default) uses convex-hull vertices and is globally optimal, but the number of hull vertices grows quickly for noisy, high-dimensional data.
  • candidate_method="random" uses extremes along random projections; cap the pool with n_candidates.
  • prune=True clusters candidates before the exhaustive search. It can discard the true extremes, so pair it with refine_greedy=True, which runs N-FINDR swaps on the full data and keeps the result only if it increases the simplex volume.
  • A RuntimeWarning is raised if the exhaustive search would exceed 50 million subsets.

Citation

GeomNMF is described in:

Jin, B., Spada, N. J., Creamean, J., Shupe, M., & Datta, A. (2025). Geometric Identification and Consistent Estimation of Source Apportionment with Application to Greenland Summit Aerosols. arXiv:2510.03616. https://arxiv.org/abs/2510.03616

If you use geom-nmf in your work, please cite this paper:

@misc{jin2025geometric,
  title         = {Geometric Identification and Consistent Estimation of Source Apportionment
                   with Application to Greenland Summit Aerosols},
  author        = {Jin, Bora and Spada, Nicholas J. and Creamean, Jessie and Shupe, Matthew
                   and Datta, Abhirup},
  year          = {2025},
  eprint        = {2510.03616},
  archivePrefix = {arXiv},
  primaryClass  = {math.ST}
}

GitHub's "Cite this repository" button (from CITATION.cff) gives the same reference in other formats.

Applications

  • Jin, B., Salmerón, B. D., McClosky, D., et al. (2025). Source apportionment of air pollution burden using geometric non-negative matrix factorization and high-throughput multi-pollutant air sensor data in Curtis Bay, Baltimore, USA. arXiv:2511.11833. https://arxiv.org/abs/2511.11833

Contributing

Bug reports, questions, and pull requests are welcome. Please open an issue to report a problem or discuss an idea. See CONTRIBUTING.md for how to set up a development environment, run the tests, and build the documentation.

License

© 2026 Bora Jin. Released under the MIT License.

Metadata

Release files for geom-nmf 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geom-nmf 0.1.1
File Size Uploaded Provenance
geom_nmf-0.1.1.tar.gz 22.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for geom-nmf 0.1.1
File Interpreter ABI Platform
geom_nmf-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 47.4 kB

Release files / geom_nmf-0.1.1.tar.gz

Download URL geom_nmf-0.1.1.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3c47728b50c42036dc6d1de7ae395cfa9d688f0be4cef0dc0f2811435cfeb08e
BLAKE2b-256 checksum
How to use checksums
303c5b8a25493bd12cec30ba54dff4c5a1720ecdb1244d5a30445ff45c70783f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Release files / geom_nmf-0.1.1-py3-none-any.whl

Download URL geom_nmf-0.1.1-py3-none-any.whl
Size 24.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0856a89b88cfde7e3974923b5477d1c885bbfbf68031d6304eff27182c9f462f
BLAKE2b-256 checksum
How to use checksums
27f9c852d59ab2f7adc312df4ebcecd2750cd217f7242a57223323bcf6520971
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Security for geom-nmf 0.1.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for geom_nmf-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page