def update(self, model):
pos_c, neg_c = get_label_colors(PALETTE)
color_code = lambda arr: np.where(arr == 1, pos_c, neg_c)
self.train_fig = figure(plot_height=400, plot_width=400,
title=template_title('train', model.trainerr), tools='',
x_range=[0, 100], y_range=[-50, 50])
self.test_fig = figure(plot_height=400, plot_width=400,
title=template_title('test', model.testerr), tools='',
x_range=[0, 100], y_range=[-50, 50])
if model.surface is not None:
X1, X2, Z = model.surface
cm = RGBAColorMapper(Z.min(), Z.max(), standard_palettes[PALETTE])
Y = cm.color(Z, alpha=IMAGE_ALPHA)
self.train_fig.image_rgba(image=[Y], x=[0], y=[-50], dw=[100], dh=[100])
self.test_fig.image_rgba(image=[Y], x=[0], y=[-50], dw=[100], dh=[100])
sample_weight = model.sample_weight
if sample_weight is None:
sample_weight = np.ones(model.train.shape[0])
sample_weight = np.sqrt(sample_weight) * DEFAULT_SIZE
self.train_fig.circle(x=model.train[:, 0], y=model.train[:, 1],
color=color_code(model.train[:, 2]),
line_color="#7c7e71", size=sample_weight,
fill_alpha=FILL_ALPHA, line_alpha=LINE_ALPHA)
self.test_fig.circle(x=model.test[:, 0], y=model.test[:, 1],
color=color_code(model.test[:, 2]),
line_color="#7c7e71", size=DEFAULT_SIZE,
fill_alpha=FILL_ALPHA, line_alpha=LINE_ALPHA)
# yeah.. i dont like that either
self.layout.children[1].children[1].children[0] = row(self.train_fig, self.test_fig)
评论列表
文章目录