https://github.com/danny-1k/torchclust
Efficient and Scalable Implementations of Clustering Algorithms using Pytorch.
https://github.com/danny-1k/torchclust
clustering-algorithm dbscan dbscan-clustering kmeans-clustering machine-learning machine-learning-algorithms pytorch
Last synced: about 2 months ago
JSON representation
Efficient and Scalable Implementations of Clustering Algorithms using Pytorch.
- Host: GitHub
- URL: https://github.com/danny-1k/torchclust
- Owner: danny-1k
- License: mit
- Created: 2024-07-15T13:11:02.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-08-22T08:59:36.000Z (10 months ago)
- Last Synced: 2025-03-24T17:11:32.942Z (3 months ago)
- Topics: clustering-algorithm, dbscan, dbscan-clustering, kmeans-clustering, machine-learning, machine-learning-algorithms, pytorch
- Language: Python
- Homepage:
- Size: 96.7 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Torchclust: Clustering Algorithms written with Pytorch for running on GPU
 [](https://linkedin.com/in/daniel-ik-human) [](https://twitter.com/1sn00s)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.*
```bash
pip install torchclust
```
## Usage#### Kmeans on gaussian blobs
```python
import torch
import matplotlib.pyplot as pltfrom torchclust.utils.datasets import make_blobs
from torchclust.centroid import KMeansx, _ = make_blobs(1000, num_features=2, centers=3)
kmeans = KMeans(num_clusters=3)
labels = kmeans.fit_predict(x)plt.scatter(x[:, 0], x[:, 1], c=labels)
plt.show()
```