pyclustering
0.10.1
pyclustring is a Python, C++ data mining library.
|
Class represents Fuzzy C-means (FCM) clustering algorithm. More...
Public Member Functions | |
def | __init__ (self, data, initial_centers, **kwargs) |
Initialize Fuzzy C-Means algorithm. More... | |
def | process (self) |
Performs cluster analysis in line with Fuzzy C-Means algorithm. More... | |
def | get_clusters (self) |
Returns allocated clusters that consists of points that most likely (in line with membership) belong to these clusters. More... | |
def | get_centers (self) |
Returns list of centers of allocated clusters. More... | |
def | get_membership (self) |
Returns cluster membership (probability) for each point in data. More... | |
Class represents Fuzzy C-means (FCM) clustering algorithm.
Fuzzy clustering is a form of clustering in which each data point can belong to more than one cluster.
Fuzzy C-Means algorithm uses two general formulas for cluster analysis. The first is to updated membership of each point:
\[w_{ij}=\frac{1}{\sum_{k=0}^{c}\left ( \frac{\left \| x_{i}-c_{j} \right \|}{\left \| x_{i}-c_{k} \right \|} \right )^{\frac{2}{m-1}}}\]
The second formula is used to update centers in line with obtained centers:
\[c_{k}=\frac{\sum_{i=0}^{N}w_{k}\left ( x_{i} \right )^{m}x_{i}}{\sum_{i=0}^{N}w_{k}\left ( x_{i} \right )^{m}}\]
Fuzzy C-Means clustering results depend on initial centers. Algorithm K-Means++ can used for center initialization from module 'pyclustering.cluster.center_initializer'.
CCORE implementation of the algorithm uses thread pool to parallelize the clustering process.
Here is an example how to perform cluster analysis using Fuzzy C-Means algorithm:
The next example shows how to perform image segmentation using Fuzzy C-Means algorithm:
def pyclustering.cluster.fcm.fcm.__init__ | ( | self, | |
data, | |||
initial_centers, | |||
** | kwargs | ||
) |
Initialize Fuzzy C-Means algorithm.
[in] | data | (array_like): Input data that is presented as array of points (objects), each point should be represented by array_like data structure. |
[in] | initial_centers | (array_like): Initial coordinates of centers of clusters that are represented by array_like data structure: [center1, center2, ...]. |
[in] | **kwargs | Arbitrary keyword arguments (available arguments: 'tolerance', 'itermax', 'm'). |
Keyword Args:
def pyclustering.cluster.fcm.fcm.get_centers | ( | self | ) |
Returns list of centers of allocated clusters.
def pyclustering.cluster.fcm.fcm.get_clusters | ( | self | ) |
Returns allocated clusters that consists of points that most likely (in line with membership) belong to these clusters.
Definition at line 147 of file fcm.py.
Referenced by pyclustering.samples.answer_reader.get_cluster_lengths(), and pyclustering.cluster.optics.optics.process().
def pyclustering.cluster.fcm.fcm.get_membership | ( | self | ) |
Returns cluster membership (probability) for each point in data.
def pyclustering.cluster.fcm.fcm.process | ( | self | ) |
Performs cluster analysis in line with Fuzzy C-Means algorithm.