Skip to main content

A library for users to use parametric spectral clustering

Project description

Parametric Spectral Clustering

This repository provides a PyTorch implementation of the Parametric Spectral Clustering (PSC) algorithm, which offers a favorable alternative to the traditional spectral clustering algorithm. PSC addresses issues related to computational efficiency, memory usage, and the absence of online learning capabilities. It serves as a versatile framework suitable for applying spectral clustering to large datasets.

Installation

Dependencies

Parametric Spectral Clustering requires:

  • Python (>= 3.8)
  • NumPy (>= 1.24.3)
  • SciPy (>= 1.10.3)
  • PyTorch (>= 1.12.1)
  • scikit-learn (>= 1.3.2)
  • Pandas (>= 2.0.3)

User installation

Use setup.py:

python setup.py install

Use pip:

pip install -i [url] ParametricSpectralClustering==0.0.14

Sample Usage

Using UCI ML hand-written digits datasets as an example.

>>> from ParametricSpectralClustering import PSC, Four_layer_FNN
>>> from sklearn.datasets import load_digits
>>> from sklearn.cluster import KMeans
>>> digits = load_digits()
>>> X = digits.data/16
>>> cluster_method = KMeans(n_clusters=10, init="k-means++", n_init=1, max_iter=100, algorithm='elkan')
>>> model = Four_layer_FNN(64, 128, 256, 64, 10)
>>> psc = PSC(model=model, clustering_method=cluster_method, n_neighbor=10, sampling_ratio=0, batch_size_data=1797)
>>> psc.fit(X)
>>> psc.save_model("model")
>>> cluster_idx = psc.predict(X)

Command line tool

After installation, you may run the following scripts directly.

python bin\run.py [data] [rate] [n_cluster] [model_path] [cluster_result_format]

The [data] can accept .txt, .csv, and .npy format of data.

The [rate] should be in float, between 0.0 and 1.0. It represent the proportion of the input data reserved for training the mapping function from the original feature space to the spectral embedding.

The [n_cluster] is the number of clusters the user intends to partition. This number needs to be lower than the total data points available within the dataset.

The [model_path] is the path to save the trained model.

The [cluster_result_format] can be either .txt or .csv. It represent the format of the cluster result.

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Author Ivy Chang Hsin Ju Tai
E-mail ivy900403@gmail.com hsinjutai@gmail.com

Project Link: TBA

Change Log

0.0.10 (2023/08/21)

  • First release

0.0.13 (2023/08/21)

  • Fix pickle

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

ParametricSpectralClustering-0.0.1.tar.gz (34.6 kB view details)

Uploaded Source

Built Distribution

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

ParametricSpectralClustering-0.0.1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file ParametricSpectralClustering-0.0.1.tar.gz.

File metadata

File hashes

Hashes for ParametricSpectralClustering-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7fdeb77d448cd40b6288a84fa29011b900183f485b74489fa3068088e0e27045
MD5 8f9ea6757f4b36aaac931d5da1e8b317
BLAKE2b-256 cc5b34b183a0f13371b38e20d807fe0201a76e35a6af6c87d891261285557430

See more details on using hashes here.

File details

Details for the file ParametricSpectralClustering-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ParametricSpectralClustering-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82418136490a233a8cac1fc53329929f9097a91f101616bb99d31e5b7c69822f
MD5 17173a8479ccc08d720586182c44509a
BLAKE2b-256 31760e2d21954df489b0e00416a3ad5038081bb5fa53310a3decd648d264c806

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