|
import pandas as pd |
|
from bokeh.plotting import figure, output_file, show |
|
from bokeh.models import Title, Div |
|
from bokeh.palettes import Category10_10 |
|
from bokeh.plotting import figure, output_file, show, curdoc |
|
from bokeh.models import Label, ColumnDataSource |
|
from bokeh.palettes import Category10_10 |
|
from bokeh.layouts import column |
|
from bokeh.models.widgets import CheckboxGroup, RadioGroup |
|
|
|
|
|
|
|
df = pd.DataFrame({ |
|
'Training database size': [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], |
|
'Number of hands on steering wheel': [70,80,76,83,84,88,91,92,93,94], |
|
'Number of hands on tablet': [97,97,98,99,99,99,99,99,99,99], |
|
|
|
}) |
|
|
|
df.to_csv('output/db_comparison.csv', index=False) |
|
|
|
df.index.name = 'Training database size' |
|
df_title = 'Accuracy evolution as function of the database size' |
|
|
|
|
|
output_file('output/db_comparison.html') |
|
p = figure(title='Accuracy evolution as function of the database size', x_axis_label='X-axis', y_axis_label='Y-axis', width=800, height=400, sizing_mode='scale_width') |
|
|
|
|
|
|
|
xaxis_title = Label(text='<b>Category</b>', x=0.5, y=-0.2, text_align='center', text_baseline='middle') |
|
p.xaxis.axis_label = "Training database size" |
|
p.yaxis.axis_label = "Accuracy" |
|
|
|
|
|
|
|
palette = Category10_10 |
|
data = {} |
|
for i, col in enumerate(df.columns[1:]): |
|
|
|
p.line(df['Training database size'], df[col], legend_label=col, line_width=3, line_color=palette[i]) |
|
data[col] = df[col] |
|
|
|
|
|
source = ColumnDataSource(data) |
|
|
|
|
|
checkbox_group = CheckboxGroup(labels=list(data.keys()), active=list(range(len(data))), width=200) |
|
|
|
|
|
radio_group = RadioGroup(labels=['Training database size', 'Category'], active=0, width=200) |
|
|
|
|
|
def update(): |
|
selected_cols = [list(data.keys())[i] for i in checkbox_group.active] |
|
x_axis = radio_group.labels[radio_group.active] |
|
new_data = {x_axis: df[x_axis]} |
|
for col in selected_cols: |
|
new_data[col] = data[col] |
|
source.data = new_data |
|
|
|
controls = column(checkbox_group, radio_group) |
|
checkbox_group.on_change('active', lambda attr, old, new: update()) |
|
radio_group.on_change('active', lambda attr, old, new: update()) |
|
|
|
|
|
layout = column(p, controls, sizing_mode ="stretch_both") |
|
show(layout) |