Hierarchical NMF
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hnmf-0.3.0.tar.gz
(678.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
hnmf-0.3.0-py3-none-any.whl
(11.7 kB
view details)
File details
Details for the file hnmf-0.3.0.tar.gz.
File metadata
- Download URL: hnmf-0.3.0.tar.gz
- Upload date:
- Size: 678.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfbc93911f65fcc813dc717cff7b642bb3c002f2af8982bae0b823ccf9e32d9c
|
|
| MD5 |
d7784fe2ff2dc3aa572a799c577591ae
|
|
| BLAKE2b-256 |
aa7dc5728b62b9f2be86936492b485154b1641af257eff447459ceec2dfd7bb5
|
File details
Details for the file hnmf-0.3.0-py3-none-any.whl.
File metadata
- Download URL: hnmf-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f56b6f54d8ddd8ef0f74f96af202b31d30455f7abec35d17f01223f6a316259
|
|
| MD5 |
a7929e6ffba966637a84ee2c99b2556a
|
|
| BLAKE2b-256 |
fe6e93a60c635d236543f82049bdadbfc00c19170de76f2b8849220f42c122b6
|