Torchclust: Clustering Algorithms written with Pytorch for running on GPU
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
- Internal
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()
Metadata
Release files for torchclust 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| torchclust-1.0.0.tar.gz | 11.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| torchclust-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / torchclust-1.0.0.tar.gz
| Download URL | torchclust-1.0.0.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a70fdf7bc6479b9ea176e090d5dfc5a95157075f80e56ba98f69f418cf8dc599
|
|
BLAKE2b-256 checksum How to use checksums |
3b3fc1372599bc8b1edb48a76364112e55312c9c849fcfee3211ba830b7b09bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / torchclust-1.0.0-py3-none-any.whl
| Download URL | torchclust-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cda1d5d5a6f1dfaf949b2df83cf8a430a1b9bc347c68b6693fe36230a452b924
|
|
BLAKE2b-256 checksum How to use checksums |
9ee6b4a6b66b9013679dd8f3004d71c2828ae254fd0ba981b45bc99b2ddd7165
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|