Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TSNE
- from sklearn.manifold import TSNE
- labels = final['Score']
- model = TSNE(n_components=2, random_state=0, perplexity =10, n_iter = 1000)
- # configuring the parameters
- # the number of components = 2
- # default perplexity = 30
- # default learning rate = 200
- # default Maximum number of iterations for the optimization = 1000
- tsne_data = model.fit_transform(tfidf_sent_vectors)
- # creating a new data frame which help us in plotting the result data
- tsne_data = np.vstack((tsne_data.T, labels)).T
- tsne_df = pd.DataFrame(data=tsne_data, columns=("Dim_1", "Dim_2", "label"))
- # Plotting the result of tsne
- sns.FacetGrid(tsne_df, hue="label", size=6).map(plt.scatter, 'Dim_1',
- 'Dim_2').add_legend()
- plt.show()
Add Comment
Please, Sign In to add comment