0
我有下面的代码,用scikit学习一些示例文本。我如何绘制matplotlib的Kmeans文本聚类结果?
train = ["is this good?", "this is bad", "some other text here", "i am hero", "blue jeans", "red carpet", "red dog", "blue sweater", "red hat", "kitty blue"]
vect = TfidfVectorizer()
X = vect.fit_transform(train)
clf = KMeans(n_clusters=3)
clf.fit(X)
centroids = clf.cluster_centers_
plt.scatter(centroids[:, 0], centroids[:, 1], marker='x', s=80, linewidths=5)
plt.show()
我无法弄清楚的事情是我如何绘制聚集的结果。 X是一个csr_matrix。我想要的是(x,y)协调每个结果绘图。
泰