from sklearncluster import KMeansfrom matplotlib import pyplotimport numpy as np# 把上面数据点分为两组非监督学习clf = KMeansn_clusters=2random_state=0x = nparray1 2 15 18 5 8 8 8 1 06 9 11clffitx # 分组########## Beg
两组数据点的中心点
centers = clf.cluster_centers_
每个数据点所属分组
labels = clf.labels_
原文地址: http://www.cveoy.top/t/topic/fIc3 著作权归作者所有。请勿转载和采集!