Skip to content

Instantly share code, notes, and snippets.

@TomHortons
Created July 19, 2017 04:11
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 TomHortons/da0094c11bf77108c41529cf515f78df to your computer and use it in GitHub Desktop.
Save TomHortons/da0094c11bf77108c41529cf515f78df to your computer and use it in GitHub Desktop.
%matplotlib inline
import plotly.offline as py
py.init_notebook_mode(connected=True)
import plotly.graph_objs as go
import plotly.tools as tls
from sklearn.manifold import TSNE
tsne = TSNE(
n_components=3,
init='random', # pca
random_state=101,
method='barnes_hut',
n_iter=500,
verbose=2
).fit_transform(img_mat)
trace1 = go.Scatter3d(
x=tsne[:,0],
y=tsne[:,1],
z=tsne[:,2],
mode='markers',
marker=dict(
sizemode='diameter',
#color = preprocessing.LabelEncoder().fit_transform(all_image_types),
#colorscale = 'Portland',
#colorbar = dict(title = 'images'),
line=dict(color='rgb(255, 255, 255)'),
opacity=0.9
)
)
data=[trace1]
layout=dict(height=800, width=800, title='3D embedding of images')
fig=dict(data=data, layout=layout)
py.iplot(fig, filename='3DBubble')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment