DESCRIPTION
python-cluster is a “simple” package that allows to create several groups (clusters) of objects from a list. It’s meant to be flexible and able to cluster any object. To ensure this kind of flexibility, you need not only to supply the list of objects, but also a function that calculates the similarity between two of those objects. For simple datatypes, like integers, this can be as simple as a subtraction, but more complex calculations are possible. Right now, it is possible to generate the clusters using a hierarchical clustering and the popular K-Means algorithm. For the hierarchical algorithm there are different “linkage” (single, complete, average and uclus) methods available.
Algorithms are based on the document found at http://www.elet.polimi.it/upload/matteucc/Clustering/tutorial_html/
USAGE
A simple python program could look like this:
>>> from cluster import HierarchicalClustering >>> data = [12,34,23,32,46,96,13] >>> cl = HierarchicalClustering(data, lambda x,y: abs(x-y)) >>> cl.getlevel(10) # get clusters of items closer than 10 [96, 46, [12, 13, 23, 34, 32]] >>> cl.getlevel(5) # get clusters of items closer than 5 [96, 46, [12, 13], 23, [34, 32]]
Note, that when you retrieve a set of clusters, it immediately starts the clustering process, which is quite complex. If you intend to create clusters from a large dataset, consider doing that in a separate thread.
For K-Means clustering it would look like this:
>>> from cluster import KMeansClustering >>> cl = KMeansClustering([(1,1), (2,1), (5,3), ...]) >>> clusters = cl.getclusters(2)
The parameter passed to getclusters is the count of clusters generated.
Metadata
Release files for cluster 1.4.1.post3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cluster-1.4.1.post3.linux-x86_64.tar.gz | 22.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cluster-1.4.1.post3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 51.0 kB
Release files / cluster-1.4.1.post3.linux-x86_64.tar.gz
| Download URL | cluster-1.4.1.post3.linux-x86_64.tar.gz |
|---|---|
| Size | 22.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
942ecd9d02572e3d5ab3111b07307026830d70eae57d6f5c1bf9bcba3abc653f
|
|
BLAKE2b-256 checksum How to use checksums |
786ece37ab112e7f704df2c0b61cee544c3b1d49c54b9e43a1beff03a4a03d71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5
|
Release files / cluster-1.4.1.post3-py2.py3-none-any.whl
| Download URL | cluster-1.4.1.post3-py2.py3-none-any.whl |
|---|---|
| Size | 29.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e05f9a79a634e942d34f015f37fb880e610f2d1adaaceb6b2e03308f16fd2a0f
|
|
BLAKE2b-256 checksum How to use checksums |
a9c2fe1c0b71de370e94da9ecb85c8e751eaa0c64c48cd774c54c9c8fc97d23c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5
|