来自微信读书:
https://weread.qq.com/web/reader/adb3241071d7c7c6adb07e4
import matplotlib.pyplot as plt from sklearn.datasets import make_blobs blobs=make_blobs(n_samples=200,random_state=1,centers=4) X_blobs=blobs[0] plt.scatter(X_blobs[:,0],X_blobs[:,1]) plt.show from sklearn.cluster import KMeans kmeans=KMeans(n_clusters=4) kmeans.fit(X_blobs)
画图程序