Skip to main content

Hierarchical NMF

Project description

hierarchical-nmf-python

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

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

hnmf-0.3.0.tar.gz (678.2 kB view details)

Uploaded Source

Built Distribution

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

hnmf-0.3.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

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

Hashes for hnmf-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cfbc93911f65fcc813dc717cff7b642bb3c002f2af8982bae0b823ccf9e32d9c
MD5 d7784fe2ff2dc3aa572a799c577591ae
BLAKE2b-256 aa7dc5728b62b9f2be86936492b485154b1641af257eff447459ceec2dfd7bb5

See more details on using hashes here.

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

Hashes for hnmf-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f56b6f54d8ddd8ef0f74f96af202b31d30455f7abec35d17f01223f6a316259
MD5 a7929e6ffba966637a84ee2c99b2556a
BLAKE2b-256 fe6e93a60c635d236543f82049bdadbfc00c19170de76f2b8849220f42c122b6

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