@@ -0,0 +1,1176 @@
+%22%22%22%0ADraw a termite plot to visualize topics and words from an LDA.%0A%22%22%22%0Aimport blaze as blz%0Afrom into import into%0A%0Aimport pandas as pd%0Aimport bokeh.plotting as plt%0Aimport numpy as np%0A%0At = blz.Data('material_science/output/simple_termite.csv')%0Adf = pd.read_csv('material_science/output/simple_termite.csv')%0A%0A# size proportional to result in Karan's example 0-10 range.%0AMAX =  t.weight.max()%0AMIN = t.weight.min()%0A%0A# Create a size variable to define the size of the the circle for the plot.%0A#t = blz.transform(t, size=np.sqrt((t.weight - MIN)/(MAX - MIN))*50)%0A%0Adata = t%0A%0AWORDS = data%5B'word'%5D.distinct()%0AWORDS = into(list, WORDS)%0A%0Atopics = data%5B'topic'%5D.distinct()%0Atopics = into(list, topics)%0A%0ATOPICS =%5B%5D%0Afor topic in topics:%0A    TOPICS.append(str(topic))%0A%0Aplt.output_file('termite.html')%0A%0Asource = pd.DataFrame(df)%0A%0Asource%5B'weight'%5D = source%5B'weight'%5D * 1000%0Adata_source = plt.ColumnDataSource(source)%0A%0Ap = plt.figure(x_range=TOPICS, y_range=WORDS,%0A       plot_width=1000, plot_height=1700,%0A       title=%22Termite Plot%22, tools='resize, save')%0A%0Ap.circle(x=%22topic%22, y=%22word%22, size=%22weight%22, fill_alpha=0.6, source=data_source)%0A#p.xaxis().major_label_orientation = np.pi/3%0Aplt.show(p)

add termite plot