INNER CODE UNIT · Python
plot_noshow_by_loc
alteryx/open_source_demos · predict-appointment-noshow/utils.py:123
def plot_noshow_by_loc(fm):
tmp = fm.groupby('neighborhood').apply(lambda df: df.tail(1))[['locations.COUNT(appointments)',
'locations.PERCENT_TRUE(appointments.no_show)']].sort_values(
by='locations.COUNT(appointments)').reset_index().reset_index()
hover = HoverTool(tooltips=[
("Prob", "@{locations.PERCENT_TRUE(appointments.no_show)}"),
("Place", "@neighborhood"),
])
source = ColumnDataSource(tmp)
p5 = figure(width=400,
height=400,
tools=[hover, 'box_zoom', 'reset', 'save'])
p5.scatter('index', 'locations.PERCENT_TRUE(appointments.no_show)', alpha=.7, source=source, color='maroon')
p5.title.text = 'Probability of no-show by Neighborhood'
p5.xaxis.axis_label = 'Neighborhoods (hover to view)'
p5.yaxis.axis_label = 'Probability of no-show'
return p5