Skip to main content

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,
            k=3,
            dissimilarity_fn=dissimilarity_fn, <---- dissimilarity function
            centroid_calc_fn=centroid_calc_fn, <---- centroid calculation function)

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.2.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

flexcluster-0.0.2-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page