我使用 python 形成了以下集群,我想标记集群内的点。我不知道该怎么做。
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
a = [262,562,733,335,544,259,682,423,769,444]
b = [19516842,16927322,14067158,12541731,10993709,10851871,10557379,10200356,10198000,9470625]
P = [list(item) for item in zip(a,b)]
kmeans = KMeans(n_clusters=2)
kmeans.fit(P)
labels = kmeans.labels_
colors = ["g.","r."]
for i in range(len(P)):
print("coordinate:",P[i], "label:", labels[i])
plt.plot(P[i][0], P[i][1], colors[labels[i]], markersize = 10)
plt.show()