当我们在谈论kmeans(4)


本系列意在长期连载分享,内容上可能也会有所增删改减;
因此如果转载,请务必保留源地址,非常感谢!
知乎专栏:https://zhuanlan.zhihu.com/data-miner
博客园:http://www.cnblogs.com/data-miner(暂时公式显示有问题)

当我们在谈论kmeans:其他聚类算法

Fuzzy C-Means (FCM)

  Fuzzy C-Means 是一种模糊聚类算法。K-means中每一个元素只能属于一个类别,而Fuzzy C-Means中一个元素以不同的概率属于每一个类别。

  Fuzzy C-Means最早出自J. C. Dunn. "A Fuzzy Relative of the ISODATA Process and Its Use in Detecting Compact Well-Separated Clusters." 1973,而后在Bezdek, James C. Pattern recognition with fuzzy objective function algorithms, 1981书中被改进。由于后者是一本书,我就没有去翻看原著了。以下给出的是现在常用的版本

  1. 类似于K-means,FCM的损失函数如下

    其中,uij满足如下限制

  2. 求取FCM损失函数极小值,依然是迭代进行,步骤如下。其中参数更新的公式,可以通过对1中公式用拉格朗日法求解。

Hierarchical Clustering

  Hierarchical Clustering即层次聚类。它有两种类型:

  • 自下而上:即最初将每个样本点看做一个类别,然后将最相似的两个样本聚合,迭代这个步骤,直到只有一个类别
  • 自上而下:即最初将所有样本看做一个类别,然后依据一定规则进行分裂,直到每个样本单独一个类别;这个方法在实际中应用很少

      Hierarchical Clustering最早出自Johnson, Stephen C. "Hierarchical clustering schemes." 1967,步骤如下:

  1. Start by assigning each item to a cluster, so that if you have N items, you now have N clusters, each containing just one item. Let the distances (similarities) between the clusters the same as the distances (similarities) between the items they contain.
  2. Find the closest (most similar) pair of clusters and merge them into a single cluster, so that now you have one cluster less.
  3. Compute distances (similarities) between the new cluster and each of the old clusters.
  4. Repeat steps 2 and 3 until all items are clustered into a single cluster of size N.

其中在步骤3中计算距离,有几种不同的计算方式:

  1. single-linkage: 当计算两个cluster之间的距离时,计算这两个cluster中距离最短的两个点的距离
  2. complete-linkage: 当计算两个cluster之间的距离时,计算这两个cluster中距离最长的两个点的距离
  3. average-linkage: 当计算两个cluster之间的距离时,计算这两个cluster中两两样本点距离的均值
  4. median-linkage: 当计算两个cluster之间的距离时,计算这两个cluster中两两样本点距离的中值

DBSCAN

  DBSCAN即Density-Based Spatial Clustering of Applications with Noise,是一种基于密度的聚类算法,最早出自Ester, Martin, et al. "A Density-Based Algorithm for Discovering Clusters in Large Spatial Databases with Noise." 1996。作者认为聚类算法应该尽量满足以下三点要求:

  • 需要的参数尽量的少。因为在实际分析场景中,一般对数据的先验信息所知甚少
  • 能有效针对不同形状的数据集。如K-means只能适用于凸的数据集
  • 对大规模数据的性能要好

      针对以上三点,作者提出了DBSCAN算法。这种算法本质是认为同一个类别的数据点集在空间中的密度是比较大的,而不同类别的数据集间的点在空间中密度很小。如下图,应该被分割成四个类别

      DBSCAN算法首先需要定义一些概念:

  1. Ε邻域:设定半径为E,则以某对象为中心,半径为Ε内的区域称为该对象的Ε邻域
  2. 核心对象:如果给定对象的Ε领域内的样本点数大于等于MinPts,则称该对象为核心对象
  3. 直接密度可达:对于样本p、q,如果样本点q在p的Ε领域内,并且p为核心对象,那么称对象q从对象p直接密度可达
  4. 密度可达:给定一系列样本点p1,p2….pn,p= p1,q= pn,假如对象pi从pi-1直接密度可达,那么对象q从对象p密度可达。
  5. 密度相连:存在样本集合D中的一点o,如果对象o到对象p和对象q都是密度可达的,那么p和q密度相联

      DBSCAN算法的具体步骤如下(引用的DBSCAN伪代码,比原文中的易懂)

  1. DBSCAN(D, eps, MinPts) {
  2. # 找到核心对象P
  3. C = 0
  4. for each point P in dataset D {
  5. if P is visited
  6. continue next point
  7. mark P as visited
  8. NeighborPts = regionQuery(P, eps)
  9. if sizeof(NeighborPts) < MinPts
  10. mark P as NOISE
  11. else {
  12. C = next cluster
  13. expandCluster(P, NeighborPts, C, eps, MinPts)
  14. }
  15. }
  16. }
  17. expandCluster(P, NeighborPts, C, eps, MinPts) {
  18. # 找到所有从核心对象P密度可达的点
  19. add P to cluster C
  20. for each point P'' in NeighborPts {
  21. if P'' is not visited {
  22. mark P'' as visited
  23. NeighborPts'' = regionQuery(P'', eps)
  24. if sizeof(NeighborPts'') >= MinPts
  25. NeighborPts = NeighborPts joined with NeighborPts''
  26. }
  27. if P'' is not yet member of any cluster
  28. add P'' to cluster C
  29. }
  30. }
  31. regionQuery(P, eps)
  32. # 查询点P的E邻域的点集
  33. return all points within P''s eps-neighborhood (including P)

原文中还有如何探索式的选择合适的参数,这里不再赘述。

Mixture of Gaussians

  在Dempster, A. P., N. M. Laird, and D. B. Rubin. "Maximum Likelihood from Incomplete Data via the EM Algorithm." 1977,作者提出了著名的EM算法(Expectation-Maximization)。在EM的应用部分,作者介绍了利用EM算法来求解混合高斯模型(GMM,Gaussian Mixture Model)的参数。
  在GMM中,GMM 的概率密度函数由 K 个 Gaussian 分布线性组成,如下。因此,利用GMM来聚类,本质就是对数据集用GMM拟合,并估计参数。求出的K个Gaussian就对应着K个类别。

以下简要介绍利用EM算法估计GMM参数的过程:

  1. 对于N个数据点,K个Gaussian分布,其联合概率密度可以表示为

  2. 对于数据xi,它属于第k个类别的概率为

  3. 利用最大似然估计,可以得到每个Gaussian的参数为。其中 N_k = \sum_{i=1}^N \gamma(i, k),并且 \pi_k = N_k/N

  4. 重复步骤2~3,直到似然函数的值收敛为止

  5. 更多的细节,可以翻阅原文,同时可以参考这个博客

Density Peaks

  此聚类算法是2014年发表在Science的一篇文章,"Clustering by fast search and find of density peaks",此算法是基于密度的一种聚类算法。传统的DBSCAN算法需要提前设定大量参数,且结果对阈值较敏感;而此算法对阈值更加鲁棒。

  1. DP算法本质上是通过两个指标来确定聚类中心。一个是局部密度,即它认为聚类中心的局部密度应该是比较大的,其公式如下

  2. 另一指标是个离密度较大点的距离,即它认为不同聚类中心之间的距离是比较大的,其公式如下

  3. 在对每个点计算指标后,选择和都比较大的点,作为聚类中心。如下

  4. 当确定了聚类中心后,某个点的类别被设定为与“离它最近,且密度比它大”的点相同的类别。可以看出,与DBSCAN类似,此聚类算法在选择所属类别时也有“传递”的概念在,因此理想情况下可以对任意形状的数据进行聚类。效果如下

  5. 对含有噪声的数据,该算法并不是直接选择全局阈值来确定噪声点。不过本质上,DP算法依然是将局部密度较小的点当成是噪声。详细的步骤,以及作者推荐的参数选择办法如下

posted @ 2017-01-18 23:09  已注销++  阅读(257)  评论(0编辑  收藏  举报