This commit is contained in:
jiangzhonglian
2017-09-08 16:24:09 +08:00
3 changed files with 7 additions and 2 deletions

View File

@@ -131,8 +131,11 @@ def kMeans(dataSet, k, distMeas=distEclud, createCent=randCent):
> 在 kMeans 的函数测试中,可能偶尔会陷入局部最小值(局部最优的结果,但不是全局最优的结果).
### K-Means 聚类算法的缺陷
在 kMeans 的函数测试中,可能偶尔会陷入局部最小值(局部最优的结果,但不是全局最优的结果).
所以为了克服 KMeans 算法收敛于局部最小值的问题,有更厉害的大佬提出了另一个称为二分K-均值(bisecting K-Means)的算法.
在 kMeans 的函数测试中,可能偶尔会陷入局部最小值(局部最优的结果,但不是全局最优的结果).
局部最小值的的情况如下:
![K-Means 局部最小值1](../images/10.KMeans/apachecn-kmeans-partial-best-result-1.jpg)
所以为了克服 KMeans 算法收敛于局部最小值的问题,有更厉害的大佬提出了另一个称之为二分K-均值(bisecting K-Means)的算法.
### 二分 K-Means 聚类算法
该算法首先将所有点作为一个簇,然后将该簇一分为二。

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -129,6 +129,8 @@ def testBiKMeans():
centList, myNewAssments = biKMeans(datMat, 3)
print 'centList=', centList
if __name__ == "__main__":
# 测试基础的函数