Understanding K-means, K-means++ and, K-medoids Clustering Algorithms

栏目: IT技术 · 发布时间: 5年前

内容简介:K-Means algorithm is a centroid based clustering technique. This technique cluster the dataset to k different cluster having an almost equal number of points. Each cluster is k-means clustering algorithm is represented by a centroid point.The centroid poin

K-Means Clustering:

K-Means algorithm is a centroid based clustering technique. This technique cluster the dataset to k different cluster having an almost equal number of points. Each cluster is k-means clustering algorithm is represented by a centroid point.

What is a centroid point?

The centroid point is the point that represents its cluster. Centroid point is the average of all the points in the set and will change in each step and will be computed by:

For the above equation,
C_i: i'th Centroid
S_i: All points belonging to set_i with centroid as C_i
x_j: j'th point from the set
||S_i||: number of points in set_i

The idea of the K-Means algorithm is to find k-centroid points and every point in the dataset will belong either of k-sets having minimum Euclidean distance.

Image 3

From the image above (Image 3), the distance of point x_i from all three centroids are d1, d2, d3, x_i point is nearest to centroid_3 with distance d3, so the point x_i will belong to the cluster of centroid_3 and this process will continue for all the points in the dataset.

Cost Function of K-Means:

The idea of the K-Means algorithm is to find k centroid points (C_1, C_1, . . . C_k) by minimizing the sum over each cluster of the sum of the square of the distance between the point and its centroid.

This cost is NP-hard and has exponential time complexity. So we use the idea of approximation using Lloyd’s Algorithm.

Lloyd’s Algorithm:

Lloyd’s algorithm is an approximation iterative algorithm used to cluster points. The steps of the algorithm are as follows:

  1. Initialization
  2. Assignment
  3. Update Centroid
  4. Repeat Step 2 and 3 until convergence.

Iterative implementation of the K-Means algorithm:

Steps #1: Initialization:

The initial k-centroids are randomly picked from the dataset of points (lines 27–28).

Steps #2: Assignment:

For each point in the dataset, find the euclidean distance between the point and all centroids (line 33). The point will be assigned to the cluster with the nearest centroid.

Steps #3: Updation of Centroid:

Update the value of the centroid with the new mean value (lines 39–40).

Steps #4: Repeat:

Repeat steps 2 and 3 unless convergence is achieved. If convergence is achieved then break the loop(line 43). Convergence refers to the condition where the previous value of centroids is equal to the updated value.

Results:

Plot for the initial dataset (Image 4)

The Plot of the dataset, (Image 4)

Clustering result plot for k=2 (Image 5)

The plot of clustering for k=2, (Image 5)

Clustering result plot for k=3 (Image 6)

The plot of clustering for k=3, (Image 6)

以上所述就是小编给大家介绍的《Understanding K-means, K-means++ and, K-medoids Clustering Algorithms》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

谷歌的断舍离:互联网企业的破坏式创新

谷歌的断舍离:互联网企业的破坏式创新

[日]辻野晃一郎 / 樊颖 / 机械工业出版社 / 2018-1 / 45.00

本书主要分为三部分: 第一部分主要讨论了世界当下如火如荼的互联网企业进军传统产业大潮,并探讨了传统企业在互联网时代的救赎之路。 第二部分主要探讨了成功体验的反面:速度与迭代,并讨论了传统企业之所以无法实现迭代与快速发展的关键原因。介绍互联网公司如何通过组织精简流程来实现高速竞争时代的机动性。 第三部分讨论了互联网时代究竟需要什么样的人才,传统企业的员工应当怎样投身互联网企业才能避......一起来看看 《谷歌的断舍离:互联网企业的破坏式创新》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具