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.
-
__class__
¶ alias of
builtins.type
-
__delattr__
¶ Implement delattr(self, name).
-
__dict__
= mappingproxy({'__module__': 'schrodinger.analysis.cluster', '__init__': <function ClusterValues.__init__>, 'getClusterMemberships': <function ClusterValues.getClusterMemberships>, 'getClusteredValues': <function ClusterValues.getClusteredValues>, 'getClusterCenters': <function ClusterValues.getClusterCenters>, '__dict__': <attribute '__dict__' of 'ClusterValues' objects>, '__weakref__': <attribute '__weakref__' of 'ClusterValues' objects>, '__doc__': None})¶
-
__dir__
() → list¶ default dir() implementation
-
__eq__
¶ Return self==value.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__module__
= 'schrodinger.analysis.cluster'¶
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-