Skip to main content

Algorithms for simplex-structured matrix factorization and polyhedral facet extraction.

Project description

Polyfacet

Polyfacet logo

Simplex-structured matrix factorization and polyhedral facet extraction in Python.

Polyfacet provides FPI and non-FPI algorithms through one Python API, with reproducible synthetic scenarios and parameter grids, bundled hyperspectral reference datasets, typed multi-scenario evaluation, metrics, visualizations, examples, and notebooks.

Install

Polyfacet requires Python 3.11 or newer:

# From an existing uv project, add the latest published Polyfacet release.
uv add polyfacet

If you are starting a new application, initialize its uv project first:

uv init my-polyfacet-project
cd my-polyfacet-project
uv add polyfacet

For development from a checkout, use uv:

git clone https://github.com/crogs-foundation/polyfacet.git
cd polyfacet
uv sync --group dev

Quick start

from polyfacet.algorithms import SOFPI
from polyfacet.data import Scenario

scenario = Scenario(rank=3, seed=7)
result = SOFPI().run(scenario.data.X, target_dim=scenario.rank, rank_X=scenario.data.r)

print(result.W.shape)  # (n_features, rank)
print(result.H.shape)  # (rank, n_samples)

Input matrices use X.shape == (n_features, n_samples): each column is one sample.

For repeatable research grids, polyfacet.data.Scenario and ScenarioMatrix support facet/interior point distributions, purity, SNR, deterministic trials, lossless save/load, and stored projections for true/estimated vertex figures.

polyfacet.evaluation.evaluate accepts algorithm factories, scenarios, and metric callables. It isolates failures and produces typed summaries plus reloadable JSON/NPZ estimates without requiring pandas.

Algorithms

Family Methods
Facet-based GFPI, EMFPI, MBFPI, SOFPI
Other factorization methods SNPA, HyperCSI, MinVolNMF, MVIE

Each method implements run(X, target_dim=..., rank_X=...) and returns factors W and H. Supply the known signal rank for noisy data instead of relying on its usually larger numerical rank. Polyfacet does not make comparative performance claims; use the included workflows to inspect the methods on data relevant to your work.

Researchers can compose the general FPI algorithm with a custom FacetExtractor from polyfacet.extractors. Runnable methods remain under polyfacet.algorithms; no generic separation API is exposed.

Data and examples

The wheel bundles Samson, Jasper Ridge, and Moffett Field. Samson and Jasper Ridge include reference factors; Moffett is a qualitative real-data example.

from polyfacet.datasets import load_moffett

scene = load_moffett(rank=3)
print(scene.name, scene.X.shape)

The repository includes an all-method Moffett notebook. It continues after an individual method fails and does not calculate ground-truth metrics because the bundled Moffett scene has no reference factors.

Documentation

License and citation

Polyfacet is distributed under the MIT License. For academic use, cite the software using CITATION.cff and cite the original publication for every algorithm used.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polyfacet-1.0.0.tar.gz (8.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polyfacet-1.0.0-py3-none-any.whl (8.6 MB view details)

Uploaded Python 3

File details

Details for the file polyfacet-1.0.0.tar.gz.

File metadata

  • Download URL: polyfacet-1.0.0.tar.gz
  • Upload date:
  • Size: 8.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for polyfacet-1.0.0.tar.gz
Algorithm Hash digest
SHA256 775d181a04458315edb4054e2c3ea81ae8821d7195be09790efc597c77fe5cd1
MD5 9ea4f6c07bdc1db216a3be1a07e6082d
BLAKE2b-256 a450fc7baf93b83acb44d1850d510efbae6c67f0951afff0c99437ee87a3cd00

See more details on using hashes here.

File details

Details for the file polyfacet-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: polyfacet-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for polyfacet-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4fa66004346e0d42d5786e7974b640a2523f0b5c8ee03c6e71a8858acf151477
MD5 ab77be5ba8eb35b583d28067948b02e8
BLAKE2b-256 3d26a70f8c058e86d424c64dd3a1b117923250717f935ce6eeda0b9988f3538f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page