schrodinger.analysis.cluster module¶
Provides a class for clustering a set of values - for example, 3D coordinates.
@copyright: Schrodinger, LLC. All rights reserved.
-
class
schrodinger.analysis.cluster.
ClusterValues
(values, n_clusters=8, **kmeans_args)¶ Bases:
object
-
__init__
(values, n_clusters=8, **kmeans_args)¶ Cluster the specified list of values (e.g. coordinates) into the given number of clusters. NOTE: This clustering algorithm is an inherintly random process, so results from different runs may not be consistent.
Parameters: - values (List or numpy array of values to cluster. Each item can be a float or a list of floats (e.g. 3D coordinates)) – Values to cluster (will be cast into a numpy array)
- n_clusters (int) – Number of clusters to generate.
Other arguments are passed directly to KMeans.
-
getClusterMemberships
()¶ Returns a list corresponding to which cluster each value was assigned. The length of the list is equal to the number of the input values. Each value ranges from 0 to (number of output clusters-1).
Used by the unit test to verify that the clustering works correctly.
-
getClusteredValues
()¶ Return a list of clustered values. Outer list represents clusters, each item (cluster) will consist of one or more input values.
-
getClusterCenters
()¶ Return a numpy array of cluster centroids.
-