Skip to content
Snippets Groups Projects
Commit c5c9734a authored by Nikolai.Hartmann's avatar Nikolai.Hartmann
Browse files

Identifiers option now optional

parent 3bc3c4f1
No related branches found
No related tags found
No related merge requests found
...@@ -151,7 +151,8 @@ class ClassificationProject(object): ...@@ -151,7 +151,8 @@ class ClassificationProject(object):
def _init_from_args(self, name, def _init_from_args(self, name,
signal_trees, bkg_trees, branches, weight_expr, identifiers, signal_trees, bkg_trees, branches, weight_expr,
identifiers=None,
selection=None, selection=None,
layers=3, layers=3,
nodes=64, nodes=64,
...@@ -178,6 +179,8 @@ class ClassificationProject(object): ...@@ -178,6 +179,8 @@ class ClassificationProject(object):
self.branches = branches self.branches = branches
self.weight_expr = weight_expr self.weight_expr = weight_expr
self.selection = selection self.selection = selection
if identifiers is None:
identifiers = []
self.identifiers = identifiers self.identifiers = identifiers
self.layers = layers self.layers = layers
self.nodes = nodes self.nodes = nodes
...@@ -730,12 +733,15 @@ class ClassificationProject(object): ...@@ -730,12 +733,15 @@ class ClassificationProject(object):
start=start, stop=start+batch_size) start=start, stop=start+batch_size)
x_eval = rec2array(x_from_tree[self.branches]) x_eval = rec2array(x_from_tree[self.branches])
# create list of booleans that indicate which events where used for training if len(self.identifiers) > 0:
df_identifiers = pd.DataFrame(x_from_tree[self.identifiers]) # create list of booleans that indicate which events where used for training
total_train_list = self.s_eventlist_train df_identifiers = pd.DataFrame(x_from_tree[self.identifiers])
total_train_list = np.concatenate((total_train_list, self.b_eventlist_train)) total_train_list = self.s_eventlist_train
merged = df_identifiers.merge(pd.DataFrame(total_train_list), on=tuple(self.identifiers), indicator=True, how="left") total_train_list = np.concatenate((total_train_list, self.b_eventlist_train))
is_train = np.array(merged["_merge"] == "both") merged = df_identifiers.merge(pd.DataFrame(total_train_list), on=tuple(self.identifiers), indicator=True, how="left")
is_train = np.array(merged["_merge"] == "both")
else:
is_train = np.zeros(len(x_eval))
# join scores and is_train array # join scores and is_train array
scores = self.evaluate(x_eval).reshape(-1) scores = self.evaluate(x_eval).reshape(-1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment