automeans
Python Library for automating the scikit-learn K-Means Clustering Algorithm by optimising the selection of number of clusters.
Introduction
Kmeans algorithm is an iterative algorithm that tries to partition the dataset into K pre-defined distinct non-overlapping subgroups (clusters) where each data point belongs to only one group. It tries to make the intra-cluster data points as similar as possible while also keeping the clusters as different (far) as possible. It assigns data points to a cluster such that the sum of the squared distance between the data points and the cluster’s centroid (arithmetic mean of all the data points that belong to that cluster) is at the minimum. The less variation we have within clusters, the more homogeneous (similar) the data points are within the same cluster.
Problem : As the name suggest, Kmeans algorithm depends upon 'K' which often times is not known by the user at the time of fitting the data. Solution : This library helps automate the selection process for the optimal number of cluster on a given data, along with an optimal fitted model.
Features
- All the main features are adopted from Scikit-Learn Kmeans Algorithm
- Getting the optimally fitted kmeans model
- Getting the optimal number of cluster
Installation
pip install automeans
Usage
Importing the model
from automeans.cluster import ameans
There are 3 metrics to choose from ['standard','kneed','silhouette']
- standard
# Initialize the model
AM = ameans(max_clusters = 5, metrics = 'standard')
# Fit on data 'X'
model, cluster = AM.fit(X)
- kneed
# Initialize the model
AM = ameans(max_clusters = 5, metrics = 'kneed')
# Fit on data 'X'
model, cluster = AM.fit(X)
- silhouette
# Initialize the model
AM = ameans(max_clusters = 5, metrics = 'silhouette')
# Fit on data 'X'
model, cluster = AM.fit(X)
Parameters
For initializing the model max_clusters : The number of maximum seeds to choose metrics : {"standard", "kneed", "silhouette"}, default="standard" Metric to choose the best number of cluster All other parameters are same as used in sklearn Kmeans algorithm
Example
import numpy as np
X = np.array([[1, 2], [2, 5], [3, 6], [8, 7], [8, 8], [7, 3]])
from automeans.cluster import ameans
# Initialize the model
AM = ameans(max_clusters = 5, metrics = 'silhouette')
# Fit on data 'X'
model, cluster = AM.fit(X)
# Predict the cluster on data 'X'
predictions = model.predict(X)
Acknowledgement
Licencse
MIT License
Copyright (c) 2020 Anshul Patel
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Metadata
Release files for automeans 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 | Provenance | |
|---|---|---|---|---|
| automeans-1.0.0.tar.gz | 6.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| automeans-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.7 kB
Release files / automeans-1.0.0.tar.gz
| Download URL | automeans-1.0.0.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
392b152bebc86bde77798f6934eac2e32c7d800428926ee6947093d2ee5c5129
|
|
BLAKE2b-256 checksum How to use checksums |
0efd88189c6d6c9dadef349ca73b28dc66253c52d3e40ee0d97fd72e4edd5352
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9
|
Release files / automeans-1.0.0-py3-none-any.whl
| Download URL | automeans-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c5294ef18bb49ecc246fa55226efa4d7b98abb9f4745223e668a59c3fd40446
|
|
BLAKE2b-256 checksum How to use checksums |
4fd085c4bab076ee8c87e8c2c0eadbfdd673bf72e50f4fb28c98de4907d0546b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9
|
Security for automeans 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.