Skip to content

Instantly share code, notes, and snippets.

@CrazyDaffodils
Last active January 13, 2020 23:43
Show Gist options
  • Select an option

  • Save CrazyDaffodils/c8af9a1c8cf3d2af868b5ddc1a078f3e to your computer and use it in GitHub Desktop.

Select an option

Save CrazyDaffodils/c8af9a1c8cf3d2af868b5ddc1a078f3e to your computer and use it in GitHub Desktop.
from sklearn.manifold import TSNE
import seaborn as sns
#Visualize data using t-SNE.
model = TSNE(learning_rate = 10, n_components = 2, random_state=123, perplexity = 30)
tsne = model.fit_transform(X_std)
tsne_df = pd.DataFrame(data=tsne, columns=['t-SNE1','t-SNE2']).join(labels)
palette = sns.color_palette("muted", n_colors=5)
sns.set_style("white")
sns.scatterplot(x='t-SNE1',y='t-SNE2',hue='Class',data=tsne_df, palette=palette, linewidth=0.2, s=30, alpha=1).set_title('t-SNE')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment