torchclust


Nametorchclust JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/danny-1k/torchclust
SummaryScalable Implementations of clustering algorithms written in Pytorch for running on the GPU.
upload_time2024-08-22 08:52:32
maintainerNone
docs_urlNone
authorDaniel Ikechukwu
requires_python>=3.7
licenseNone
keywords machine learning deep learning pytorch clustering
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![](./assets/logo.png)

# Torchclust: Clustering Algorithms written with Pytorch for running on GPU
![License](https://img.shields.io/github/license/hmunachi/nanodl?style=flat-square) [![LinkedIn](https://img.shields.io/badge/-LinkedIn-blue?style=flat-square&logo=linkedin&logoColor=white)](https://linkedin.com/in/daniel-ik-human) [![Twitter](https://img.shields.io/twitter/follow/1sn00s?style=social)](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 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()
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/danny-1k/torchclust",
    "name": "torchclust",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "machine learning deep learning pytorch clustering",
    "author": "Daniel Ikechukwu",
    "author_email": "ttdanielik@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3b/3f/c1372599bc8b1edb48a76364112e55312c9c849fcfee3211ba830b7b09bb/torchclust-1.0.0.tar.gz",
    "platform": null,
    "description": "![](./assets/logo.png)\n\n# Torchclust: Clustering Algorithms written with Pytorch for running on GPU\n![License](https://img.shields.io/github/license/hmunachi/nanodl?style=flat-square) [![LinkedIn](https://img.shields.io/badge/-LinkedIn-blue?style=flat-square&logo=linkedin&logoColor=white)](https://linkedin.com/in/daniel-ik-human) [![Twitter](https://img.shields.io/twitter/follow/1sn00s?style=social)](https://twitter.com/1sn00s)\n\nTorchclust 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.\n\nTorchclust features implementations of common clustering algorithms with a scikit-learn feel.\n\n## Implemented algorithms\n- Centroid-based Clustering\n    - KMeans\n    - MeanShift\n- Density-based Clustering\n    - DBSCAN\n    - Gaussian Mixture Model\n- Deep / Learning-based Clustering\n    - Self-Organising Maps\n- Metrics\n    - Internal\n        - Silhouette Score\n        - Interia\n        - Davies-Bouldin Index \n        - Calinski-Harabasz Score / Variance Ratio Criterion\n    - External\n        - Purity Score\n        - Rand Index\n        - Adjusted Rand Index\n        - Mutual Information\n        - Normalised Mutual Information\n\n## Contributing\nThis is still an ongoing project and contributions from the opensource community are warmly welcomed.\n\nContributions can be made in various forms:\n- Writing docs / Updating README\n- Fixings bugs\n- More efficient implementations of algorithnms\n- Or even implementing more algorithms\n\n## Installation\n\n*Be sure the GPU version of pytorch is installed if you intend to run the algorithms on GPU.*\n\n```bash\npip install torchclust\n```\n## Usage\n\n#### Kmeans on gaussian blobs\n```python\nimport torch\nimport matplotlib.pyplot as plt\n\nfrom torchclust.utils.datasets import make_blobs\nfrom torchclust.centroid import KMeans\n\nx, _ = make_blobs(1000, num_features=2, centers=3)\nx = torch.from_numpy(x)\n\nkmeans = KMeans(num_clusters=3)\nlabels = kmeans.fit_predict(x)\n\nplt.scatter(x[:, 0], x[:, 1], c=labels)\nplt.show()\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Scalable Implementations of clustering algorithms written in Pytorch for running on the GPU.",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/danny-1k/torchclust"
    },
    "split_keywords": [
        "machine",
        "learning",
        "deep",
        "learning",
        "pytorch",
        "clustering"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9ee6b4a6b66b9013679dd8f3004d71c2828ae254fd0ba981b45bc99b2ddd7165",
                "md5": "48e0c2f2b43d7469ff146683dfacd086",
                "sha256": "cda1d5d5a6f1dfaf949b2df83cf8a430a1b9bc347c68b6693fe36230a452b924"
            },
            "downloads": -1,
            "filename": "torchclust-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "48e0c2f2b43d7469ff146683dfacd086",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 13660,
            "upload_time": "2024-08-22T08:52:30",
            "upload_time_iso_8601": "2024-08-22T08:52:30.384722Z",
            "url": "https://files.pythonhosted.org/packages/9e/e6/b4a6b66b9013679dd8f3004d71c2828ae254fd0ba981b45bc99b2ddd7165/torchclust-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b3fc1372599bc8b1edb48a76364112e55312c9c849fcfee3211ba830b7b09bb",
                "md5": "10e6ff27610abe4ad239bb7719255233",
                "sha256": "a70fdf7bc6479b9ea176e090d5dfc5a95157075f80e56ba98f69f418cf8dc599"
            },
            "downloads": -1,
            "filename": "torchclust-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "10e6ff27610abe4ad239bb7719255233",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 11286,
            "upload_time": "2024-08-22T08:52:32",
            "upload_time_iso_8601": "2024-08-22T08:52:32.011453Z",
            "url": "https://files.pythonhosted.org/packages/3b/3f/c1372599bc8b1edb48a76364112e55312c9c849fcfee3211ba830b7b09bb/torchclust-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-22 08:52:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "danny-1k",
    "github_project": "torchclust",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "torchclust"
}
        
Elapsed time: 0.30427s