Created
March 18, 2019 21:32
-
-
Save iandewancker/82305053ad8924ce97df27c438face8d to your computer and use it in GitHub Desktop.
Interactive biz using Bokeh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_interactive_plot(y_pred, y_true, gids, img_pattern): | |
colors=["red", "gold", "limegreen"] | |
projected_points = projectSimplex(y_pred) | |
labels = ['0', '1', '2+'] | |
from bokeh.plotting import figure, output_file, show, ColumnDataSource | |
from bokeh.models import HoverTool | |
URLs = [] | |
web_colors = [] | |
X_plot = projected_points[:,0] | |
Y_plot = projected_points[:,1] | |
for i, p in enumerate(projected_points): | |
URLs.append("http://ec2-18-188-29-240.us-east-2.compute.amazonaws.com:8008/{}/{}".format(gids[i],img_pattern)) | |
web_colors.append(colors[np.argmax(y_true[i])]) | |
source = ColumnDataSource(data=dict( | |
x=X_plot, | |
y=Y_plot, | |
imgs=URLs, | |
color=web_colors, | |
probs0=y_pred[:,0], | |
probs1=y_pred[:,1], | |
probs2=y_pred[:,2], | |
true0=y_true[:,0], | |
true1=y_true[:,1], | |
true2=y_true[:,2], | |
)) | |
hover = HoverTool( tooltips=""" | |
<div> | |
<div> | |
<img | |
src="@imgs" height="320" alt="@imgs" width="240" | |
style="float: right; margin: 0px 0px 0px 0px; opacity:1.0;" | |
></img> | |
<p> | |
probs : @probs0 @probs1 @probs2 | |
</p> | |
<p> | |
true : @true0 @true1 @true2 | |
</p> | |
</div> | |
</div> | |
""" | |
) | |
output_file("/home/ubuntu/data/stow_verification/gvc_embedding.html") | |
p = figure(plot_width=800, plot_height=800, tools=[hover, 'pan', 'wheel_zoom'], | |
title="CNN GVC Embedding") | |
# add a square renderer with a size, color, and alpha | |
p.circle('x', 'y', size=20, source=source, color='color', alpha=0.25) | |
# show the results | |
show(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment