コード例 #1
0
def draw_vert_avg(ax, statistics):
    print('draw_vert_avg')
    ymax = ax.get_ylim()[1]

    a_hits_df = stat_tools.find_first_hits(statistics, acc.acc_requirement)
    a_mean = a_hits_df['end_time'].mean()

    a_line = ax.vlines(a_mean,
                       ymin=0,
                       ymax=ymax,
                       colors=c.bg_dot_color,
                       linewidth=3,
                       path_effects=[c.white_outline])
    _set_zorder(a_line)

    best_params = _find_best_params(statistics)
    best_stat = statistics.select_by_values(best_params)
    b_hits_df = stat_tools.find_first_hits(best_stat, acc.acc_requirement)
    b_mean = b_hits_df['end_time'].mean()

    b_color = next(c.iter_fg_dot_color())
    b_line = ax.vlines(b_mean,
                       ymin=0,
                       ymax=ymax,
                       colors=b_color,
                       linewidth=3,
                       path_effects=[c.white_outline])
    _set_zorder(b_line)

    _add_2_important([(a_mean, 0), (b_mean, 0)])
コード例 #2
0
def _draw_hits(ax, stat, color=None):
    print('\t_draw_hits')
    hits_df = stat_tools.find_first_hits(stat, acc.acc_requirement)
    xs = hits_df['end_time']
    ys = hits_df['val_acc']
    path = ax.scatter(xs, ys, c=color, edgecolor='white', s=72)

    _add_2_important(list(zip(xs, ys)))
    _set_zorder(path)
コード例 #3
0
def draw_box_plot(ax, statistics, by_param):
    df = stat_tools.find_first_hits(statistics, acc.acc_requirement)
    df = df.dropna(axis='index')
    colors = c.iter_fg_dot_color()

    data = []
    param_vals = []
    for param_val, local_df in df.groupby(by_param).__iter__():
        data.append(local_df['end_time'])
        param_vals.append(param_val)

    box_plot = ax.boxplot(data, vert=False, labels=param_vals,
                          notch=False, patch_artist=True)

    for box, flier, color in zip(box_plot['boxes'], box_plot['fliers'], colors):
        box.set_facecolor(color)
        flier.set_markerfacecolor(color)

    ax.set(xlabel='end_time(s)', ylabel=by_param)
コード例 #4
0
def collect_hits(config):
    hostname_all = []
    hit_times_all = []
    hit_accs_all = []

    for host in config['hosts']:
        print(f'processing host="{host}"')
        statistics = stat_tools.Statistics(**config['hosts'][host])
        hit_df = stat_tools.find_first_hits(statistics,
                                            acc.acc_requirement,
                                            reverse=acc.reverse_acc_req)

        hit_times = hit_df['end_time'].values
        hit_accs = hit_df['val_acc'].values

        hostname_all.append(host)
        hit_times_all.append(hit_times)
        hit_accs_all.append(hit_accs)

    return hostname_all, hit_times_all, hit_accs_all
コード例 #5
0
def draw_fig(statistics, by_param, facecolor=c.white):
    hit_df = stat_tools.find_first_hits(statistics, acc.acc_requirement)
    num_groups = hit_df.loc[:, by_param].nunique()

    fig = plt.figure(figsize=[10, 4 * num_groups], constrained_layout=True)

    grid = gridspec.GridSpec(num_groups, 1, figure=fig)
    grid.update(wspace=0.025, hspace=0.01)

    axs = [fig.add_subplot(spec) for spec in grid]

    draw_group(axs, draw_hist, hit_df, by_param, label=True)
    draw_group(axs, draw_norm_dist, hit_df, by_param)

    fig.set_facecolor(facecolor)
    for ax in axs:
        ax.set_facecolor(facecolor)
        ax.set_ylabel('probabilistic distribution(%)')
    # only on last(bottom) plot
    ax.set_xlabel('end_time(%)')

    return fig
コード例 #6
0
def draw_fig(statistics, by_param, facecolor=c.white):
    fig, ax = plt.subplots()

    hit_df = stat_tools.find_first_hits(statistics, acc.acc_requirement)

    draw_group(ax,
               draw_cdf,
               hit_df,
               by_param,
               label=True,
               n_bins=n_bins,
               z_offset=10)
    draw_group(ax, draw_theo_cdf, hit_df, by_param, on=False)

    fig.set_facecolor(facecolor)
    ax.set_facecolor(facecolor)

    ax.set(xlabel="end_time(s)", ylabel="Cumulative Distribution(%)")
    ax.legend(title=by_param, loc='upper left')

    fig.tight_layout()

    return fig
コード例 #7
0
def main():
    options = parse_argv()

    statistics = stat_tools.Statistics(path=options.path,
                                       params=options.params)
    base_dir = os.path.dirname(options.path)

    first_hit_df = stat_tools.find_first_hits(statistics, acc.acc_requirement)

    for param in statistics.params:
        print(f'param = {param}')

        fig = draw_fig(first_hit_df, param=param, facecolor=options.facecolor)

        # showing figure in window
        if not options.quiet:
            plt.show()

        # save image to the same directory as statistics.csv
        image_path = os.path.join(base_dir, f'first_hit_avg_bar_{param}_.png')
        fig.savefig(image_path)

        # close current figure before drawing again
        plt.close(fig)