コード例 #1
0
def graph_error_bar(restraints, x_axis, y_axis, error_bar, diff):
    df, header = load()
    xs, ys, errors = [], [], []
    for r in restraints:
        filt = filter_data(df, header, r)
        x1, y1, _ = extract_plotable_data(filt, header, x_axis, y_axis)
        x2, y2, _ = extract_plotable_data(filt, header, x_axis, error_bar)

        y1, x1, max_len1 = multi_average(x1, y1, 'sample')
        y2, x2, max_len2 = multi_average(x2, y2, 'sample')

        # add desired data.
        xs.append(x1[-1])
        ys.append(y1[-1])
        errors.append(y2[-1])

    # xs, ys, errors
    plot_seaborn_bar(xs, ys, errors, x_axis, y_axis, diff)
コード例 #2
0
def main(restraints, x_axis, y_axis, one_graph=False):
    df, header = load()
    filt = filter_data(df, header, restraints)
    xs, ys, hs = extract_plotable_data(filt, header, x_axis, y_axis)

    if not (one_graph):
        for x, y, h in zip(xs, ys, hs):
            plot(x, y, x_axis, y_axis, h, header, one_graph)
    else:
        plot(xs, ys, x_axis, y_axis, hs, header, one_graph)

    return None
コード例 #3
0
def overlay_graph(restraints, y_name, y_axis1, y_axis2, config='single'):
    """ Same restraints, different variables (i.e. token_auc + entropy). """
    df, header = load()
    filt = filter_data(df, header, restraints)
    x1, y1, h1 = extract_plotable_data(filt, header, 'epoch', y_axis1)
    x2, y2, h2 = extract_plotable_data(filt, header, 'epoch', y_axis2)

    if config == 'single':
        y1 = y1[0]
        y2 = y2[0]
        x1 = x1[0]
        x2 = x2[0]

    elif config == 'avg':
        y1 = list(np.mean(y1, axis=0))
        y2 = list(np.mean(y2, axis=0))

    diff = [y_axis1] * len(x1) + [y_axis2] * len(x2)
    x1 = x1 + x2
    y1 = y1 + y2
    plot_seaborn(x1, y1, diff, y_axis1 + " vs. " + y_axis2, 'epochs',
                 'combined')
    return None
コード例 #4
0
def overlay_graph_diff(restraints, y_name, x_axis, y_axis, config='single'):
    """ Different restraints, same variables. Y_name should be an array (len 2) of names. """
    df, header = load()
    filts, xs, ys, hs = [], [], [], []
    for r in restraints:
        filt = filter_data(df, header, r)
        x, y, h = extract_plotable_data(filt, header, x_axis, y_axis)
        filts.append(filt)
        xs.append(x)
        ys.append(y)
        hs.append(h)

    if config == 'single':
        xs = [x[0] for x in xs]
        ys = [y[0] for y in ys]
        hs = [h[0] for h in hs]

    elif config == 'avg':
        new_xs, new_ys = [], []
        for x, y in zip(xs, ys):
            ty, tx, max_len = multi_average(x, y)
            new_xs.append(tx)
            new_ys.append(ty)

        xs, ys = new_xs, new_ys

    diff = [
        item for sublist in [[y_name[i]] * len(xs[i]) for i in range(len(xs))]
        for item in sublist
    ]
    diff_name = 'Experiment Variants'
    fx = []  # final x, final y
    fy = []
    for x, y in zip(xs, ys):
        fx.extend(x)
        fy.extend(y)

    plot_seaborn(fx, fy, diff, diff_name, x_axis, y_axis)
コード例 #5
0
def negative_epoch_graph(restraints,
                         diff,
                         y_name,
                         y_axis1,
                         y_axis2,
                         config='avg'):
    df, header = load()
    xs, ys, splits, dashed, colors = [], [], [], [], []
    color_order = [
        (0.00392156862745098, 0.45098039215686275, 0.6980392156862745),
        (0.00392156862745098, 0.45098039215686275, 0.6980392156862745),
        (0.00784313725490196, 0.6196078431372549, 0.45098039215686275),
        (0.00784313725490196, 0.6196078431372549, 0.45098039215686275),
    ]
    i = 0
    c_order = 0
    for r in restraints:
        filt = filter_data(df, header, r)
        x1, y1, _ = extract_plotable_data(filt, header, 'epoch', y_axis1)
        x2, y2, _ = extract_plotable_data(filt, header, 'epoch', y_axis2)

        if config == 'avg' or config == 'sample':
            if len(y1) != 0:

                y1, x1, max_len1 = multi_average(x1, y1, config)
                y2, x2, max_len2 = multi_average(x2, y2, config)

                # change value of x1 and x2
                x1 = list(np.asarray(x1) - len(x1))
                x2 = list(np.asarray(x2) - 1)

                # connect the lines
                x1.append(0.0)
                y1.append(y2[0])

                # set up data
                x = x1 + x2
                y = y1 + y2
                splits += [i] * (max_len1 + 1) + [i] * max_len2
                dashed.append(True)
                colors += [color_order[c_order]]
                i += 1
                c_order += 1

            else:
                y, x, max_len = multi_average(x2, y2, config)
                x = list(np.asarray(x) - 1)
                splits += [i] * max_len
                dashed.append(False)
                colors += [color_order[c_order]]
                i += 1
                c_order += 1

        # add data
        xs.append(x)
        ys.append(y)

    fx = []  # final x, final y
    fy = []
    for x, y in zip(xs, ys):
        fx.extend(x)
        fy.extend(y)

    plot_seaborn_neg(fx, fy, diff, splits, dashed, colors, 'epoch', y_axis1)
    return None