Esempio n. 1
0
def main():
    # pylint: disable=missing-function-docstring
    setup_logging()
    cmdargs = parse_cmdargs()

    dgen, _, _, outdir, _, eval_specs = standard_eval_prologue(
        cmdargs, PRESETS_EVAL)

    plotdir = os.path.join(outdir, 'targets')
    os.makedirs(plotdir, exist_ok=True)

    true_energies = get_true_energies(dgen)
    weights = dgen.weights

    for label, energy in true_energies.items():
        for log_scale in [True, False]:
            f, _, rhist = plot_energy(energy, weights,
                                      eval_specs['name_map'][label],
                                      eval_specs['hist'][label], log_scale)

            save_fig(f, os.path.join(plotdir,
                                     '%s_log(%s)' % (label, log_scale)),
                     cmdargs.ext)

        np.savetxt(os.path.join(plotdir, "%s_hist.txt" % (label)), rhist.hist)
        np.savetxt(os.path.join(plotdir, "%s_bins.txt" % (label)),
                   rhist.bins_x)
Esempio n. 2
0
def prologue(cmdargs):
    """Load dataset, model and initialize output directory"""
    dgen, args, model, outdir, plotdir, eval_specs = \
        standard_eval_prologue(cmdargs, PRESETS_EVAL)

    plotdir = os.path.join(outdir,
                           'input_importance_perturb_%.3e' % (cmdargs.smear))
    os.makedirs(plotdir, exist_ok=True)

    return (args, model, dgen, plotdir, eval_specs)
Esempio n. 3
0
def main():
    # pylint: disable=missing-function-docstring
    setup_logging()
    cmdargs = parse_cmdargs()

    dgen, args, model, _outdir, plotdir, eval_specs = standard_eval_prologue(
        cmdargs, PRESETS_EVAL)

    pred_model_dict = predict_energies(args, dgen, model)
    true_dict = get_true_energies(dgen)
    pred_base_dict = get_base_energies(dgen, eval_specs['base_map'])

    make_binstat_plots(pred_model_dict, pred_base_dict, true_dict,
                       dgen.weights, eval_specs, plotdir, cmdargs.ext)
Esempio n. 4
0
def main():
    # pylint: disable=missing-function-docstring
    setup_logging()
    cmdargs = parse_cmdargs()

    dgen, args, model, outdir, plotdir, eval_specs = standard_eval_prologue(
        cmdargs, PRESETS_EVAL)

    (stats_model_dict, hCont_model_dict), (stats_base_dict, hCont_base_dict) \
        = evaluate(
            args, dgen, model, eval_specs['base_map'], eval_specs['fom'],
            FOM_FIT_MARGIN, outdir
        )

    plot_fom([
        (hCont_base_dict, stats_base_dict, 'Base ', 'left', 'C0'),
        (hCont_model_dict, stats_model_dict, 'Model', 'right', 'C1'),
    ],
             eval_specs['fom'],
             fname='%s/fom' % (plotdir),
             ext=cmdargs.ext)