Пример #1
0
transitions = dat_5[~dat_5.shifted_next & ~dat_5.shifted_prev]
speeds = transitions.groupby(["ch_prev",
                              "ch_next"]).ms.agg(["mean", "std",
                                                  "count"]).reset_index()
speeds = speeds[speeds.ch_prev != speeds.ch_next]
speeds = speeds[speeds["count"] > 100]
speeds = speeds[speeds["mean"] > 100]
display(speeds.sort_values(by="mean", ascending=False).reset_index(drop=True))

generated = set()

for k, group in speeds.groupby("ch_prev"):
    config = k + "_" + "".join(sorted(group.ch_next.tolist()))
    if config in generated:
        continue
    q_kb.fill_color(k, 'tab:blue')
    for ch in group.ch_next:
        q_kb.fill_color(ch, 'tab:orange')
    q_kb.make_colormap()
    logger.info(config)
    plt.show()
    q_kb.save(os.path.join(image_dir, f"transition_vis/vis_{config}.png"))

for k, group in speeds.groupby("ch_next"):
    config = "".join(sorted(group.ch_prev.tolist())) + "_" + k
    if config in generated:
        continue
    q_kb.fill_color(k, 'tab:orange')
    for ch in group.ch_prev:
        q_kb.fill_color(ch, 'tab:blue')
    q_kb.make_colormap()
Пример #2
0
    if key in (0, -1, 13):
        continue
    i = key - 1
    color = col_colors[i]
    legend_elements.append(
        Line2D([0], [0],
               color='w',
               markerfacecolor=color,
               alpha=0.5,
               marker='o',
               markersize=15,
               label=key))
    for ch in group.ch.tolist():
        if ch == None or ch in q_kb.left_shift or ch in q_kb.right_shift:
            continue
        q_kb.fill_color(ch, color)
q_kb.make_colormap()
leg = q_kb.ax.legend(
    handles=legend_elements,
    loc='lower center',
    ncol=5,
    shadow=False,
    bbox_to_anchor=(.5, -.3),
    prop={'size': 12},
)
leg.get_frame().set_edgecolor('black')
plt.show()
q_kb.save(os.path.join(image_dir, "columns.png"))
logger.info("Generated Digit Visualization")

## Digit Labels