Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created June 16, 2021 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/e2f5228450e01623c6186084e9af7925 to your computer and use it in GitHub Desktop.
Save amankharwal/e2f5228450e01623c6186084e9af7925 to your computer and use it in GitHub Desktop.
from sklearn.manifold import TSNE
import plotly.express as px
df = px.data.iris()
features = df.loc[:, :'petal_width']
tsne = TSNE(n_components=2, perplexity=20, random_state=1000)
projections = tsne.fit_transform(features)
fig = px.scatter(
projections, x=0, y=1,
color=df.species, labels={'color': 'species'}
)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment