title: How to plot the output of k-means clustering of word embedding using python?
body: <p>I have used gensims word embeddings to find vectors of each word. Then I used K-means to find clusters of word. There are close to <code>10,000</code> tokens/words and I want to plot them.</p>
  
  <p>I want to plot the result in the following way:</p>
  
  <ul>
  <li>Annotate points with name of <code>words</code></li>
  <li>Different color for clusters</li>
  </ul>
  
  <p>Here is what I have done. </p>
  
  <pre><code>tsne = TSNE(perplexity=40, n_components=2, init='pca', n_iter=500)#, random_state=13)
  
  
  def tsne_plot(data):
      "Creates and TSNE model and plots it"
  
      data=data.sample(n = 500).reset_index()
      word=data["word"]
      cluster=data["clusters"]
      data=data.drop(["clusters","word"],axis=1)
  
      X = tsne.fit_transform(data)
  
      plt.figure(figsize=(48, 48)) 
      for i in range(len(X)):
          plt.scatter(X[:,0][i],X[:,1][i],c=cluster[i])
          plt.annotate(word[i],
                       xy=(X[:,0][i],X[:,1][i]),
                       xytext=(3, 2),
                       textcoords='offset points',
                       ha='right',
                       va='bottom')
      plt.show()
  
  tsne_plot(data)
  </code></pre>
  
  <p>Though it's annotating the <code>words</code> but failing to color different groups/clusters?</p>
  
  <p>Anyother other approach which annoates with word anmes and colors different clusters?</p>