Skip to main content

Scalable Implementations of clustering algorithms written in Pytorch for running on the GPU.

Project description

Torchclust: Clustering Algorithms written with Pytorch for running on GPU

License LinkedIn Twitter

Torchclust was developed to solve the issue of having to convert Pytorch Tensors to Numpy arrays and moving them to the CPU from the GPU in order to utilise frameworks such as scikit-learn.

Torchclust features implementations of common clustering algorithms with a scikit-learn feel.

Implemented algorithms

  • Centroid-based Clustering
    • KMeans
    • MeanShift
  • Density-based Clustering
    • DBSCAN
    • Gaussian Mixture Model
  • Deep / Learning-based Clustering
    • Self-Organising Maps
  • Metrics
    • Internal
      • Silhouette Score
      • Interia
      • Davies-Bouldin Index
      • Calinski-Harabasz Score / Variance Ratio Criterion
    • External
      • Purity Score
      • Rand Index
      • Adjusted Rand Index
      • Mutual Information
      • Normalised Mutual Information

Contributing

This is still an ongoing project and contributions from the opensource community are warmly welcomed.

Contributions can be made in various forms:

  • Writing docs / Updating README
  • Fixings bugs
  • More efficient implementations of algorithnms
  • Or even implementing more algorithms

Installation

Be sure the GPU version of pytorch is installed if you intend to run the algorithms on GPU.

pip install torchclust

Usage

Kmeans on gaussian blobs

import torch
import matplotlib.pyplot as plt

from torchclust.utils.datasets import make_blobs
from torchclust.centroid import KMeans

x, _ = make_blobs(1000, num_features=2, centers=3)
x = torch.from_numpy(x)

kmeans = KMeans(num_clusters=3)
labels = kmeans.fit_predict(x)

plt.scatter(x[:, 0], x[:, 1], c=labels)
plt.show()

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

torchclust-1.0.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

torchclust-1.0.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file torchclust-1.0.0.tar.gz.

File metadata

  • Download URL: torchclust-1.0.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for torchclust-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a70fdf7bc6479b9ea176e090d5dfc5a95157075f80e56ba98f69f418cf8dc599
MD5 10e6ff27610abe4ad239bb7719255233
BLAKE2b-256 3b3fc1372599bc8b1edb48a76364112e55312c9c849fcfee3211ba830b7b09bb

See more details on using hashes here.

File details

Details for the file torchclust-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: torchclust-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for torchclust-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cda1d5d5a6f1dfaf949b2df83cf8a430a1b9bc347c68b6693fe36230a452b924
MD5 48e0c2f2b43d7469ff146683dfacd086
BLAKE2b-256 9ee6b4a6b66b9013679dd8f3004d71c2828ae254fd0ba981b45bc99b2ddd7165

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