Exemplo n.º 1
0
def make_plot(points, truth, label_truth, label_pred, fname):
    truth_cent = truth.mean()
    truth_std = truth.std()
    points = sorted(points)

    smooth = True
    window = 15
    points = np.array(points)
    if not smooth:
        xvals = points[:, 0]
        yvals = points[:, 1]
        ydown = points[:, 2]
        yup = points[:, 2]
    else:
        xvals = points[:, 0][window - 1:]
        yvals = moving_average(points[:, 1], n=window)
        ydown = moving_average(points[:, 2], n=window)
        yup = moving_average(points[:, 2], n=window)

    # hpred = r.TH1F("hpred",100,truth.min(),truth.max())
    # htruth = r.TH1F("htruth",100,truth.min(),truth.max())
    # fill_fast(hpred, yvals)
    # fill_fast(htruth, truth)

    ply.plot_graph(
        [
            ([0., max(xvals)], [truth_cent, truth_cent],
             [truth_std, truth_std], [truth_std, truth_std]),
            (xvals, yvals, ydown, yup),
        ],
        colors=[r.kAzure + 2, r.kRed - 2],
        legend_labels=[label_truth, label_pred],
        options={
            "legend_alignment": "bottom right",
            "legend_scalex": 0.7,
            "xaxis_label": "epoch",
            "yaxis_label": label_pred,
            "output_name": fname,
            "output_ic": True,
        })
Exemplo n.º 2
0
            for v1, v2 in zip(vals[:len(vals) / 2], vals[len(vals) / 2:])], [])
legend_labels = sum(
    [[l1, l2]
     for l1, l2 in zip(legend_labels[:len(vals) / 2], legend_labels[len(vals) /
                                                                    2:])], [])
colors = sum([[t, t] for t in temp], [])
draw_styles = [0, 2] * (len(legend_labels) / 2)

ply.plot_graph(
    vals,
    colors=colors,
    legend_labels=legend_labels,
    draw_styles=draw_styles,
    options={
        "legend_alignment": "bottom right",
        "legend_scalex": 1.45,
        "legend_scaley": 1.5,
        "xaxis_label": "bkg. eff.",
        "yaxis_label": "sig. eff.",
        "title": "DY: prompt vs unmatched e & b/c#rightarrow e",
        "xaxis_log": True,
        "yaxis_log": True,
        "xaxis_range": [0.005, 0.8],
        "yaxis_range": [0.7, 1.0],
        # "xaxis_range": [0.005,0.8],
        # "yaxis_range": [0.5,1.0],
        # "output_name": "plots/roc.pdf",
        "output_name": fname,
        "output_ic": True,
    })
Exemplo n.º 3
0
quantities_real = get_quantities(data[:, range(1, 9)])
epoch_chi2 = []

fnames = sorted(fnames, key=lambda x: int(x.rsplit("_", 1)[-1].split(".")[0]))
for fname in fnames:
    data = np.load(fname)
    epoch = int(fname.rsplit("_", 1)[-1].split(".")[0])
    if epoch < 500: continue
    quantities_gen = get_quantities(data)
    tot_chi2 = 0.
    for key in quantities_gen:
        tot_chi2 += get_redchi2(quantities_real[key], quantities_gen[key])
    print epoch, tot_chi2
    epoch_chi2.append([epoch, tot_chi2])
epoch_chi2 = np.array(epoch_chi2)

ply.plot_graph(
    [(epoch_chi2[:, 0], epoch_chi2[:, 1])],
    colors=[r.kAzure + 2],
    legend_labels=["model1"],
    options={
        "legend_alignment": "top right",
        "legend_scalex": 0.7,
        "xaxis_label": "epoch",
        "yaxis_label": "#Sigma(#chi^{2}/ndof)",
        "yaxis_log": True,
        "title": "#Sigma(#chi^{2}/ndof) vs epoch",
        "output_name": "plots/chi2_vs_epoch.pdf",
        "output_ic": True,
    })
Exemplo n.º 4
0
models = []
for modeldir,name in modelinfos:
    fname_history = "{}/history.pkl".format(modeldir)
    if not os.path.exists(fname_history): continue
    data = pickle.load(open(fname_history,"r"))
    models.append( Model(data,name) )

varinfo = [
        ["d_loss", "discriminator loss"],
        ["g_loss", "generator loss"],
        ["d_acc", "discriminator accuracy"],
        ["mass_mu", "m_{ll} mean"],
        ["mass_sig", "m_{ll} width"],
        ["time", "cumulative time [minutes]"],
        ]
for varname, varlabel in varinfo:
    ply.plot_graph(
        [m.get_points(varname) for m in models],
        legend_labels = [m.name for m in models],
        options = {
            "legend_alignment": "top left",
            # "legend_scalex": 0.7,
            "xaxis_label": "epoch",
            "yaxis_label": varlabel,
            "output_name": "plots/{}.pdf".format(varname),
            "output_ic": True,
            }
        )