回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我使用下面的python代码使用kmeans集群我的数据点。在</p>
<pre><code>data = np.array([[30, 17, 10, 32, 32], [18, 20, 6, 20, 15], [10, 8, 10, 20, 21], [3, 16, 20, 10, 17], [3, 15, 21, 17, 20]])
kmeans_clustering = KMeans( n_clusters = 3 )
idx = kmeans_clustering.fit_predict( data )
#use t-sne
X = TSNE(n_components=2).fit_transform( data )
fig = plt.figure(1)
plt.clf()
#plot graph
colors = np.array([x for x in 'bgrcmykbgrcmykbgrcmykbgrcmyk'])
plt.scatter(X[:,0], X[:,1], c=colors[kmeans_clustering.labels_])
plt.title('K-Means (t-SNE)')
plt.show()
</code></pre>
<p>然而,我得到的星团图是错误的,因为我把一切都集中在一点上。
<img src="https://i.stack.imgur.com/70oI3.jpg" alt="cluster plot"/></p>
<p>因此,请让我知道我的代码哪里出错了?我想在我的散点图中分别查看kmeans集群。在</p>
<p><strong>编辑</strong></p>
<p>我得到的t-sne山谷如下。在</p>
^{pr2}$