From d4687d98dd318c102576156726f8e97135f95ebe Mon Sep 17 00:00:00 2001 From: Nikolai Hartmann <Nikolai.Hartmann@physik.uni-muenchen.de> Date: Mon, 27 Aug 2018 15:35:04 +0200 Subject: [PATCH] earlier argparse in plot_NN_2D.py --- scripts/plot_NN_2D.py | 53 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/scripts/plot_NN_2D.py b/scripts/plot_NN_2D.py index f5f9fee..3ddb6ba 100755 --- a/scripts/plot_NN_2D.py +++ b/scripts/plot_NN_2D.py @@ -2,30 +2,6 @@ import sys import argparse -import logging -logging.basicConfig() - -import numpy as np - -import ROOT -ROOT.gROOT.SetBatch() -ROOT.PyConfig.IgnoreCommandLineOptions = True - -from KerasROOTClassification import load_from_dir -from KerasROOTClassification.plotting import ( - get_mean_event, - plot_NN_vs_var_2D, - plot_profile_2D, - plot_hist_2D_events, - plot_cond_avg_actmax_2D, - plot_NN_vs_var_2D_all, -) -from KerasROOTClassification.utils import ( - get_single_neuron_function, - get_max_activation_events, - weighted_quantile, - get_ranges -) parser = argparse.ArgumentParser(description='Create various 2D plots for a single neuron') parser.add_argument("project_dir") @@ -53,6 +29,31 @@ parser.add_argument("-s", "--step-size", help="step size for activation maximisa args = parser.parse_args() +import logging +logging.basicConfig() + +import numpy as np + +import ROOT +ROOT.gROOT.SetBatch() +ROOT.PyConfig.IgnoreCommandLineOptions = True + +from KerasROOTClassification import load_from_dir +from KerasROOTClassification.plotting import ( + get_mean_event, + plot_NN_vs_var_2D, + plot_profile_2D, + plot_hist_2D_events, + plot_cond_avg_actmax_2D, + plot_NN_vs_var_2D_all, +) +from KerasROOTClassification.utils import ( + get_single_neuron_function, + get_max_activation_events, + weighted_quantile, + get_ranges +) + if args.all_neurons and (not args.mode.startswith("mean")): parser.error("--all-neurons currently only supported for mean_sig and mean_bkg") @@ -94,8 +95,8 @@ except AttributeError: # percentilesx = weighted_quantile(varx_test[x_not_masked], [0.01, 0.99], sample_weight=total_weights[x_not_masked]) # percentilesy = weighted_quantile(vary_test[y_not_masked], [0.01, 0.99], sample_weight=total_weights[y_not_masked]) -percentilesx = get_ranges(c.x_test, [0.01, 0.99], total_weights, mask_value=mask_value, filter_index=varx_index)[0] -percentilesy = get_ranges(c.x_test, [0.01, 0.99], total_weights, mask_value=mask_value, filter_index=vary_index)[0] +percentilesx = get_ranges(c.x_test, [0.01, 0.99], total_weights, mask_value=mask_value, filter_index=varx_index, max_evts=10000)[0][0] +percentilesy = get_ranges(c.x_test, [0.01, 0.99], total_weights, mask_value=mask_value, filter_index=vary_index, max_evts=10000)[0][0] if args.xrange is not None: -- GitLab