Class represents clustering algorithm K-Medoids. More...
Public Member Functions | |
def | __init__ (self, data, initial_index_medoids, tolerance=0.001, ccore=True, kwargs) |
Constructor of clustering algorithm K-Medoids. More... | |
def | process (self) |
Performs cluster analysis in line with rules of K-Medoids algorithm. More... | |
def | predict (self, points) |
Calculates the closest cluster to each point. More... | |
def | get_clusters (self) |
Returns list of allocated clusters, each cluster contains indexes of objects in list of data. More... | |
def | get_medoids (self) |
Returns list of medoids of allocated clusters represented by indexes from the input data. More... | |
def | get_cluster_encoding (self) |
Returns clustering result representation type that indicate how clusters are encoded. More... | |
Class represents clustering algorithm K-Medoids.
The algorithm is less sensitive to outliers tham K-Means. The principle difference between K-Medoids and K-Medians is that K-Medoids uses existed points from input data space as medoids, but median in K-Medians can be unreal object (not from input data space).
Clustering example:
Metric for calculation distance between points can be specified by parameter additional 'metric':
Distance matrix can be used instead of sequence of points to increase performance and for that purpose parameter 'data_type' should be used:
Definition at line 41 of file kmedoids.py.
def pyclustering.cluster.kmedoids.kmedoids.__init__ | ( | self, | |
data, | |||
initial_index_medoids, | |||
tolerance = 0.001 , |
|||
ccore = True , |
|||
kwargs | |||
) |
Constructor of clustering algorithm K-Medoids.
[in] | data | (list): Input data that is presented as list of points (objects), each point should be represented by list or tuple. |
[in] | initial_index_medoids | (list): Indexes of intial medoids (indexes of points in input data). |
[in] | tolerance | (double): Stop condition: if maximum value of distance change of medoids of clusters is less than tolerance than algorithm will stop processing. |
[in] | ccore | (bool): If specified than CCORE library (C++ pyclustering library) is used for clustering instead of Python code. |
[in] | **kwargs | Arbitrary keyword arguments (available arguments: 'metric', 'data_type', 'itermax'). |
Keyword Args:
Definition at line 109 of file kmedoids.py.
def pyclustering.cluster.kmedoids.kmedoids.get_cluster_encoding | ( | self | ) |
Returns clustering result representation type that indicate how clusters are encoded.
Definition at line 247 of file kmedoids.py.
def pyclustering.cluster.kmedoids.kmedoids.get_clusters | ( | self | ) |
Returns list of allocated clusters, each cluster contains indexes of objects in list of data.
Definition at line 223 of file kmedoids.py.
Referenced by pyclustering.samples.answer_reader.get_cluster_lengths(), and pyclustering.cluster.optics.optics.process().
def pyclustering.cluster.kmedoids.kmedoids.get_medoids | ( | self | ) |
Returns list of medoids of allocated clusters represented by indexes from the input data.
Definition at line 235 of file kmedoids.py.
def pyclustering.cluster.kmedoids.kmedoids.predict | ( | self, | |
points | |||
) |
Calculates the closest cluster to each point.
[in] | points | (array_like): Points for which closest clusters are calculated. |
An example how to calculate (or predict) the closest cluster to specified points.
Definition at line 177 of file kmedoids.py.
def pyclustering.cluster.kmedoids.kmedoids.process | ( | self | ) |
Performs cluster analysis in line with rules of K-Medoids algorithm.
Definition at line 143 of file kmedoids.py.