flexible clustering algorithm that allows user-define dissimilarity an centroid calculation
Project description
flexcluster
flexcluster is a python package that provides a flexible implementation for clustering algorithms based on K-means.
The package provides a generic clustering function that allows customization with callback parameters:
- dissimilarity function - function(datapoint1, datapoint2) : int - function that defines the distance between 2 data points.
- centroid calculation function - function(datapoints : np.array) : datapoint - function that calculates a centroid given an array of datapoints.
centroids, centroid_labels = clustering(
data, <--------------------------------- array of elements
k=3, <---------------------------------- number of clusters
dissimilarity_fn=dissimilarity_fn, <---- dissimilarity function
centroid_calc_fn=centroid_calc_fn, <---- centroid calculation function
max_tries=5) <-------------------------- number of clustering tries (get best result)
centroids => calculated centroids per cluster
centroid_labels => map with a numeric key for each cluster and value is an array of item indexes
Kmeans and kmedoids are also provided in this package as shortcuts to specific cluster configuration.
centroids, centroid_labels = kmeans(data, k=3)
centroids, centroid_labels = kmedoids(data, k=3)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flexcluster-0.0.4.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for flexcluster-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d8e8fd23dc844d30998f28704e14e908a7e1d0447745acac2e3633ad2a404eb |
|
MD5 | 267ceaa5b1358f5eaccc209de35d4a65 |
|
BLAKE2b-256 | 9c3d6ff268f9598942b7078fe7e1aeb1d51ae17535c89914bdd9a73d30d1d456 |