K-Means聚类算法
来源:互联网 发布:昆明理工大学教务网络 编辑:程序博客网 时间:2024/05/06 17:37
KMeans算法的基本思想是初始随机给定K个簇中心,按照最邻近原则把待分类样本点分到各个簇。然后按平均法重新计算各个簇的质心,从而确定新的簇心。一直迭代,直到簇心的移动距离小于某个给定的值。
K-Means聚类算法主要分为三个步骤:
(1)第一步是为待聚类的点寻找聚类中心
(2)第二步是计算每个点到聚类中心的距离,将每个点聚类到离该点最近的聚类中去
(3)第三步是计算每个聚类中所有点的坐标平均值,并将这个平均值作为新的聚类中心
反复执行(2)、(3),直到聚类中心不再进行大范围移动或者聚类次数达到要求为止
下图展示了对n个样本点进行K-means聚类的效果,这里k取2:
(a)未聚类的初始点集
(b)随机选取两个点作为聚类中心
(c)计算每个点到聚类中心的距离,并聚类到离该点最近的聚类中去
(d)计算每个聚类中所有点的坐标平均值,并将这个平均值作为新的聚类中心
(e)重复(c),计算每个点到聚类中心的距离,并聚类到离该点最近的聚类中去
(f)重复(d),计算每个聚类中所有点的坐标平均值,并将这个平均值作为新的聚类中心
Matlab实现:
详见:http://www.oschina.net/code/snippet_176897_10239
执行结果:
>> Kmeans
6 iterations, total sum of distances = 204.821
10 iterations, total sum of distances = 205.886
16 iterations, total sum of distances = 204.821
9 iterations, total sum of distances = 205.886
........
9 iterations, total sum of distances = 205.886
8 iterations, total sum of distances = 204.821
8 iterations, total sum of distances = 204.821
14 iterations, total sum of distances = 205.886
14 iterations, total sum of distances = 205.886
6 iterations, total sum of distances = 204.821
Ctrs =
SumD =
聚类效果:
Matlab R2012a Documentation:
http://www.mathworks.com.sixxs.org/help/toolbox/stats/kmeans.html?nocookie=true
stackoverflow:kmeans example in matlab does not run:
http://stackoverflow.com/questions/8411117/kmeans-example-in-matlab-does-not-run
- k-means聚类算法
- k-means聚类算法
- K-means聚类算法
- K-means聚类算法
- K-means聚类算法
- K-means聚类算法
- K-means聚类算法
- K-means聚类算法
- K-MEANS聚类算法
- k-means聚类算法
- K-means聚类算法
- 聚类算法 K-means
- K-means聚类算法
- K-means聚类算法
- K-means聚类算法
- 聚类算法:K-means
- K-means聚类算法
- K-means聚类算法
- matlab生成满足二维高斯(正…
- MATLAB中的meshgrid函数与mesh()函…
- Kolmogorov-Smirnov test
- k均值聚类(K-means)(转载)
- 基于W5500的物联网环境信息监测系统
- K-Means聚类算法
- 阿拉伯人与伊斯兰教
- Cocos2D-X设计模式:管理者模式
- kernel PCA的基本推导
- 怎样才能多出科研成果(转)
- 重用执行计划
- 2013年长春站C题 背包+概率
- Eclipse快捷键
- WEB-INF 有关的目录路径问题总结