Class represents clustering algorithm K-Medians. More...
Public Member Functions | |
def | __init__ (self, data, initial_medians, tolerance=0.001, ccore=True, kwargs) |
Constructor of clustering algorithm K-Medians. More... | |
def | process (self) |
Performs cluster analysis in line with rules of K-Medians 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_medians (self) |
Returns list of centers of allocated clusters. More... | |
def | get_total_wce (self) |
Returns sum of metric errors that depends on metric that was used for clustering (by default SSE - Sum of Squared Errors). More... | |
def | get_cluster_encoding (self) |
Returns clustering result representation type that indicate how clusters are encoded. More... | |
Class represents clustering algorithm K-Medians.
The algorithm is less sensitive to outliers than K-Means. Medians are calculated instead of centroids.
Example:
Definition at line 41 of file kmedians.py.
def pyclustering.cluster.kmedians.kmedians.__init__ | ( | self, | |
data, | |||
initial_medians, | |||
tolerance = 0.001 , |
|||
ccore = True , |
|||
kwargs | |||
) |
Constructor of clustering algorithm K-Medians.
[in] | data | (list): Input data that is presented as list of points (objects), each point should be represented by list or tuple. |
[in] | initial_medians | (list): Initial coordinates of medians of clusters that are represented by list: [center1, center2, ...]. |
[in] | tolerance | (double): Stop condition: if maximum value of change of centers of clusters is less than tolerance than algorithm will stop processing |
[in] | ccore | (bool): Defines should be CCORE library (C++ pyclustering library) used instead of Python code or not. |
[in] | **kwargs | Arbitrary keyword arguments (available arguments: 'metric', 'itermax'). |
Keyword Args:
Definition at line 75 of file kmedians.py.
def pyclustering.cluster.kmedians.kmedians.get_cluster_encoding | ( | self | ) |
Returns clustering result representation type that indicate how clusters are encoded.
Definition at line 234 of file kmedians.py.
def pyclustering.cluster.kmedians.kmedians.get_clusters | ( | self | ) |
Returns list of allocated clusters, each cluster contains indexes of objects in list of data.
Definition at line 193 of file kmedians.py.
Referenced by pyclustering.samples.answer_reader.get_cluster_lengths(), and pyclustering.cluster.optics.optics.process().
def pyclustering.cluster.kmedians.kmedians.get_medians | ( | self | ) |
Returns list of centers of allocated clusters.
Definition at line 205 of file kmedians.py.
def pyclustering.cluster.kmedians.kmedians.get_total_wce | ( | self | ) |
Returns sum of metric errors that depends on metric that was used for clustering (by default SSE - Sum of Squared Errors).
Sum of metric errors is calculated using distance between point and its center:
Definition at line 220 of file kmedians.py.
def pyclustering.cluster.kmedians.kmedians.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 148 of file kmedians.py.
def pyclustering.cluster.kmedians.kmedians.process | ( | self | ) |
Performs cluster analysis in line with rules of K-Medians algorithm.
Definition at line 108 of file kmedians.py.