hierarchical-nmf-python
- fork of https://github.com/rudvlf0413/hierarchical-nmf-python
- with familiar SKLearn interface
Installation
pip install hnmf
Usage
20 Newsgroups
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import TfidfVectorizer
from hnmf import HierarchicalNMF
n_features = 1000
n_leaves = 20
data, _ = fetch_20newsgroups(shuffle=True, random_state=1,
remove=('headers', 'footers', 'quotes'),
return_X_y=True)
# Use tf-idf features for NMF.
tfidf = TfidfVectorizer(max_df=0.95, min_df=2,
max_features=n_features,
stop_words='english')
X = tfidf.fit_transform(data)
id2feature = {i: token for i, token in enumerate(tfidf.get_feature_names_out())}
# hNMF
model = HierarchicalNMF(k=n_leaves)
model.fit(X)
model.cluster_features()
Documentation
To build the documentation:
mkdocs build
To preview locally:
mkdocs serve
The documentation will be built to the docs/ folder for GitHub Pages.
Reference
-
Papers: Fast rank-2 nonnegative matrix factorization for hierarchical document clustering
-
Originally adapted from MATLAB: https://github.com/dakuang/hiernmf2
Metadata
Release files for hNMF 0.3.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 |
|---|---|---|---|---|
| hnmf-0.3.2.tar.gz | 679.8 kB | Without provenance | Details for hnmf-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hnmf-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for hnmf-0.3.2-py3-none-any.whl |
Total release size: 691.7 kB
Release files / hnmf-0.3.2.tar.gz
| Download URL | hnmf-0.3.2.tar.gz |
|---|---|
| Size | 679.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf23aed8c291223613480162e418ab4ed1ee35659e3f47f410caf93489845b2b
|
|
BLAKE2b-256 checksum How to use checksums |
b2bf426c81725b4898023ff0acf063bc7274238afab42e7bfc133a440b775889
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Release files / hnmf-0.3.2-py3-none-any.whl
| Download URL | hnmf-0.3.2-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0dd51290765b1ce565b3753d15ab548aaa07c28f09a1914fad6c325d50d927e6
|
|
BLAKE2b-256 checksum How to use checksums |
f7763c869905728be11153cfbb2ae903a490bdd063b581f576c4f1ce173198e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Security for hNMF 0.3.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.