K-means一族聚类算法
outline
无监督算法简介
如上图所示,众所周知,机器学习分为有监督、无监督和强化学习三大块,其中聚类和降维都属于无监督学习。其实如果仔细想一下,聚类也可以某些时候也可以用来降维。常用的聚类算法有:K-means、Mean shift、DBSCAN、GMM、Hierarchical clustering等。下面将详细介绍K-means算法。
K-means
1. 聚类相关算法简介
输入: 集合, 距离度量函数, 聚类的数目k;
输出: 数据的k个聚类
方法1. K-means: 寻找k个中心点,使得
最小.
minimize the sum of squared distance from each item to its nearest averaged center.
方法2. K-median: 寻找k个中心点,使得
最小.
minimize the sum of distance from each item to its nearest median (sum of distance !! not sum of squared distance.
方法3. K-center: 寻找k个中心点,使得
最小.
minimize the maximum distance from each item to its nearest cluster centers (maximum distance !! not sum of distance.
2. K-means算法(Lloyd’s method)
选取k个初始聚类中心(作为初始cluster);
repeat:
1)对每个样本点,计算得到距其最近的质心,将其类别标为该质心所对应的cluster;(这一步其实是EM算法的E操作)
2)重新计算k个cluser对应的质心(EM算法的M操作);
until 聚类中心不再发生变化