机器学习中的聚类与分类算法
1. 聚类算法概述
聚类算法是一种能够在未明确具体目标的情况下,检测数据中模式的方法,在数据挖掘等过程中具有重要意义。下面将介绍几种常见的聚类算法。
1.1 K-Means 聚类
K-Means 聚类是一种经典的聚类算法。以下是一段关于 K-Means++ 初始化质心的代码:
centroids = []
centroids.append(data[nump.random.randint(data.shape[0]), :])
plotcentroids(data, nump.array(centroids))
## compute remaining k - 1 centroids
for c_id in range(k - 1):
## initialize a list to store distances of data
## points from nearest centroid
dist = []
for i in range(data.shape[0]):
point = data[i, :]
d = sys.maxsize
## compute distance of 'point' from each of the
## previously selected centroid and store the minimum distance
for j in range(len(centroids)):
temp_
超级会员免费看
订阅专栏 解锁全文
2万+

被折叠的 条评论
为什么被折叠?



