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.2.tar.gz
(679.8 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.2-py3-none-any.whl
(11.9 kB
view details)
File details
Details for the file hnmf-0.3.2.tar.gz.
File metadata
- Download URL: hnmf-0.3.2.tar.gz
- Upload date:
- Size: 679.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf23aed8c291223613480162e418ab4ed1ee35659e3f47f410caf93489845b2b
|
|
| MD5 |
68cacdd0c3b935c693bc282e73dc8c13
|
|
| BLAKE2b-256 |
b2bf426c81725b4898023ff0acf063bc7274238afab42e7bfc133a440b775889
|
File details
Details for the file hnmf-0.3.2-py3-none-any.whl.
File metadata
- Download URL: hnmf-0.3.2-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dd51290765b1ce565b3753d15ab548aaa07c28f09a1914fad6c325d50d927e6
|
|
| MD5 |
a3273ebe46db04e313cd59c67615b566
|
|
| BLAKE2b-256 |
f7763c869905728be11153cfbb2ae903a490bdd063b581f576c4f1ce173198e3
|