Guest User

Untitled

a guest
Jan 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #TSNE
  2.  
  3. from sklearn.manifold import TSNE
  4.  
  5. labels = final['Score']
  6.  
  7.  
  8. model = TSNE(n_components=2, random_state=0, perplexity =10, n_iter = 1000)
  9. # configuring the parameters
  10. # the number of components = 2
  11. # default perplexity = 30
  12. # default learning rate = 200
  13. # default Maximum number of iterations for the optimization = 1000
  14.  
  15.  
  16. tsne_data = model.fit_transform(tfidf_sent_vectors)
  17.  
  18.  
  19. # creating a new data frame which help us in plotting the result data
  20. tsne_data = np.vstack((tsne_data.T, labels)).T
  21. tsne_df = pd.DataFrame(data=tsne_data, columns=("Dim_1", "Dim_2", "label"))
  22.  
  23. # Plotting the result of tsne
  24. sns.FacetGrid(tsne_df, hue="label", size=6).map(plt.scatter, 'Dim_1',
  25. 'Dim_2').add_legend()
  26. plt.show()
Add Comment
Please, Sign In to add comment