-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
############################################################################# | ||
## © Copyright CERN 2018. All rights not expressly granted are reserved. ## | ||
## © Copyright CERN 2023. All rights not expressly granted are reserved. ## | ||
## Author: [email protected] ## | ||
## This program is free software: you can redistribute it and/or modify it ## | ||
## under the terms of the GNU General Public License as published by the ## | ||
|
@@ -54,10 +54,11 @@ def __init__(self, data_param, case, typean, model_config, binmin, | |
|
||
self.logger = get_logger() | ||
|
||
dirprefix = data_param["multi"]["data"].get("prefix_dir", "") | ||
dirprefixdata = data_param["multi"]["data"].get("prefix_dir", "") | ||
dirprefixmc = data_param["multi"]["mc"].get("prefix_dir", "") | ||
dirprefix_ml = data_param["ml"].get("prefix_dir_ml", "") | ||
dirmcml = dirprefix + data_param["multi"]["mc"]["pkl_skimmed_merge_for_ml_all"] | ||
dirdataml = dirprefix + data_param["multi"]["data"]["pkl_skimmed_merge_for_ml_all"] | ||
dirmcml = dirprefixmc + data_param["multi"]["mc"]["pkl_skimmed_merge_for_ml_all"] | ||
dirdataml = dirprefixdata + data_param["multi"]["data"]["pkl_skimmed_merge_for_ml_all"] | ||
self.v_bin = data_param["var_binning"] | ||
#directory | ||
self.dirmlout = dirprefix_ml + data_param["ml"]["mlout"] | ||
|
@@ -75,6 +76,8 @@ def __init__(self, data_param, case, typean, model_config, binmin, | |
print(f"rm -r {self.dirmlplot}") | ||
self.logger.fatal("Please remove above directories as indicated above first and " \ | ||
"run again") | ||
if self.steps_done == None: | ||
self.steps_done = [] | ||
|
||
#ml file names | ||
self.n_reco = data_param["files_names"]["namefile_reco"] | ||
|
@@ -205,7 +208,7 @@ def __init__(self, data_param, case, typean, model_config, binmin, | |
self.f_mltest_applied = f"{self.dirmlout}/testsample_{self.s_suffix}_mldecision.pkl" | ||
self.df_mltest_applied = None | ||
|
||
print(training_var) | ||
self.logger.info('training variables: %s', training_var) | ||
|
||
def create_suffix(self): | ||
string_selection = createstringselection(self.v_bin, self.p_binmin, self.p_binmax) | ||
|
@@ -320,16 +323,10 @@ def preparesample(self): | |
self.step_done("preparemlsamples") | ||
|
||
def step_done(self, step): | ||
if self.steps_done is None: | ||
self.steps_done = [] | ||
|
||
step_name = f"{step}_{self.p_binmin}_{self.p_binmax}" | ||
if step_name in self.steps_done: | ||
print("\n\n") | ||
self.logger.warning("Done ML step %s already. It's skipped now. Remove the step " \ | ||
"from the list in the following file", step_name) | ||
print(self.file_steps_done) | ||
print("\n\n") | ||
"from the list in %s", step_name, self.file_steps_done) | ||
return True | ||
|
||
# Add this steps and update the corresponsing file | ||
|
@@ -445,7 +442,7 @@ def do_test(self): | |
self.df_mltest, self.v_train, self.v_sig) | ||
df_ml_test_to_root = self.dirmlout+"/testsample_%s_mldecision.root" % (self.s_suffix) | ||
pickle.dump(self.df_mltest_applied, openfile(self.f_mltest_applied, "wb"), protocol=4) | ||
write_tree(df_ml_test_to_root, self.n_treetest, self.df_mltest_applied) | ||
# write_tree(df_ml_test_to_root, self.n_treetest, self.df_mltest_applied) | ||
|
||
def do_apply(self): | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters