Skip to content

Instantly share code, notes, and snippets.

@kusal1990
Created June 2, 2022 18:12
Show Gist options
  • Save kusal1990/3e3624cb07826de5210cfb62fe6d0f16 to your computer and use it in GitHub Desktop.
Save kusal1990/3e3624cb07826de5210cfb62fe6d0f16 to your computer and use it in GitHub Desktop.
from sklearn.manifold import TSNE
tsne = TSNE(n_components=2, perplexity=30, learning_rate=200, random_state=42)
X_embedding = tsne.fit_transform(df_signal_train)
y = np.array(df_signal_train['target'])
tsne = np.hstack((X_embedding, y.reshape(-1,1)))
tsne_to_df = pd.DataFrame(data=tsne, columns=['Dimension_x','Dimension_y','Score'])
colors = {0:'red', 1:'blue', 2:'green'}
plt.scatter(tsne_to_df['Dimension_x'], tsne_to_df['Dimension_y'], c=tsne_to_df['Score'].apply(lambda x: colors[x]))
plt.show()
del(tsne)
@kusal1990
Copy link
Author

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment