]> code.communitydata.science - cdsc_reddit.git/blob - visualization/tsne_vis.py
1e2aeaef3f810277cbea532659ae5d58f8cfe275
[cdsc_reddit.git] / visualization / tsne_vis.py
1 import pyarrow
2 import altair as alt
3 alt.data_transformers.disable_max_rows()
4 alt.data_transformers.enable('data_server')
5 import pandas as pd
6 from numpy import random
7 import numpy as np
8 from sklearn.manifold import TSNE
9
10 pd.read_feather("tsne_subreddit_fit.feather")
11
12 slider = alt.binding_range(min=1,max=100,step=1,name='zoom: ')
13 selector = alt.selection_single(name='zoomselect',fields=['zoom'],bind='scales',init={'zoom':1})
14
15 xrange = plot_data.x.max()-plot_data.x.min()
16 yrange = plot_data.y.max()-plot_data.y.min()
17
18 chart = alt.Chart(plot_data).mark_text().encode(
19     alt.X('x',axis=alt.Axis(grid=False)),
20     alt.Y('y',axis=alt.Axis(grid=False)),
21     text='subreddit')
22
23 #chart = chart.add_selection(selector)
24
25 chart = chart.configure_view(
26     continuousHeight=xrange/20,
27     continuousWidth=yrange/20
28 )
29
30 amount_shown = lambda zoom: {'width':xrange/zoom,'height':yrange/zoom}
31
32 alt.data_transformers.enable('default')
33 chart = chart.properties(width=1000,height=1000)
34 chart = chart.interactive()
35 chart.save("test_tsne_whole.html")
36 chart = chart.properties(width=10000,height=10000)
37 chart.save("test_tsne_whole.svg")

Community Data Science Collective || Want to submit a patch?