k-MEANS距离

算欧拉距离:

1.np.sqrt(np.sum(np.square(X[i]-centroids[j])))

2.np.linalg.norm(X[i]-cemtroids[j])

算数组中最小值的索引:

np.argmin(distance)

3.取数组满足条件的索引

1 X[idx==1]
2 points=np.where(idx==1)    X[points,:]

4.

np.sum(X[points,:],axis=1)
axis=1 //表示行 axis=0 //表示列

5.ravel()是将数组变为一维数组

posted @ 2023-04-26 20:59  iu本u  阅读(26)  评论(0)    收藏  举报