In [73]:
import pandas as pd
import pickle
import itertools
from bokeh.plotting import figure, output_notebook, show
from bokeh.palettes import Category10
from bokeh.layouts import gridplot
from bokeh.models import Title
output_notebook()
In [2]:
def extract_scores(result):
extracted = {}
for kind in ("train_", "test_"):
for score in ("AUC", "F1 Max"):
extracted[kind + score] = result[kind + "res"][score]
extracted.update({k:v for k, v in result.items() if not k.endswith("res")})
return extracted
In [23]:
results = pickle.load(open("BinaryF.p", "rb"))
scores = [extract_scores(x) for x in results]
df = pd.DataFrame(scores)
df.head()
Out[23]:
In [25]:
model_order = ["L5", "L10_L5", "L30_L15", "L15_L10_L5", "L30_L20_L10"]
sequence_order = ["(3, 1)", "(4, 1, 3)"]
df["model"] = pd.Categorical(df["model"], model_order)
df["sequence"] = pd.Categorical(df["sequence"].astype(str), sequence_order)
Out[25]:
In [98]:
width = 200
height = 125
def create_sub_plot(sub_df):
p = figure(y_range=(-0.1, 1.1), width=width, height=height)
for (size, size_df), color in zip(sub_df.groupby("size"), Category10[10]):
series = size_df.groupby("epochs")["test_F1 Max"].mean().sort_index()
p.line(x=series.index, y=series.values, line_color=color, legend=size)
p.circle(x=series.index, y=series.values, line_color=color, fill_color=color, legend=size)
p.yaxis.minor_tick_line_color = None
p.xaxis.minor_tick_line_color = None
p.xaxis.axis_label = "Epochs"
p.yaxis.axis_label = "F1 Score"
return p
In [99]:
plots = []
for idx, ((model, sequence), sub_df) in enumerate(df.groupby(["model", "sequence"])):
p = create_sub_plot(sub_df)
if idx % 2 == 0:
p.add_layout(Title(text=model, align="center"), "left")
p.plot_width = width + 50
else:
p.yaxis.visible = False
if idx >= 8:
p.add_layout(Title(text=sequence, align="center"), "below")
p.plot_height = height + 50
else:
p.xaxis.visible = False
if idx != 1:
p.legend.visible = False
plots.append(p)
In [100]:
show(gridplot(plots, ncols=2))
In [ ]: