阅读背景:

kmeans学习笔记轮廓系数以及使用KMeans做矢量量化_weixin_45271076的博客_kmeans 轮廓系数

来源:互联网 




from sklearn.cluster import KMeans
cluster=KMeans(n_clusters=3,random_state=0).fit(X)
y_pred=cluster.labels_
color=["red","pink","orange","gray"]
#根据聚类结果画图
fig,ax1=plt.subplots(1)
for i in range(3):
    ax1.scatter(X[y_pred==i,0],X[y_pred==i,1]
               ,marker='o'
               ,s=8,
               c=color[i])
 
ax1.scatter(cluster.cluster_centers_[:,0],cluster.cluster_centers_[:,1]
           ,marker="x"
           ,s=20,
            c="black"
        )
plt.show()  
from sklearn.cluster import KMeans



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: