Skip to content

Commit

Permalink
Improve packaging and some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
qgp committed Dec 1, 2023
1 parent 7017eab commit 9b2d0ea
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
18 changes: 18 additions & 0 deletions machine_learning_hep/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#############################################################################
## © Copyright CERN 2023. All rights not expressly granted are reserved. ##
## ##
## 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 ##
## Free Software Foundation, either version 3 of the License, or (at your ##
## option) any later version. This program is distributed in the hope that ##
## it will be useful, but WITHOUT ANY WARRANTY; without even the implied ##
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ##
## See the GNU General Public License for more details. ##
## You should have received a copy of the GNU General Public License ##
## along with this program. if not, see <https://www.gnu.org/licenses/>. ##
#############################################################################

import sys
from machine_learning_hep.steer_analysis import main

sys.exit(main())
2 changes: 1 addition & 1 deletion machine_learning_hep/logger.py
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 ##
Expand Down
9 changes: 3 additions & 6 deletions machine_learning_hep/steer_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
import yaml
from pkg_resources import resource_stream

# To set batch mode immediately
from ROOT import gROOT # pylint: disable=import-error, no-name-in-module

from machine_learning_hep.multiprocesser import MultiProcesser
from machine_learning_hep.processer import Processer
from machine_learning_hep.processerdhadrons import ProcesserDhadrons
Expand Down Expand Up @@ -55,9 +52,6 @@
def do_entire_analysis(data_config: dict, data_param: dict, data_param_overwrite: dict, # pylint: disable=too-many-locals, too-many-statements, too-many-branches
data_model: dict, run_param: dict, clean: bool):

# Disable any graphical stuff. No TCanvases opened and shown by default
gROOT.SetBatch(True)

logger = get_logger()
logger.info("Do analysis chain")

Expand Down Expand Up @@ -527,3 +521,6 @@ def main():
# Run the chain
do_entire_analysis(run_config, db_analysis, db_analysis_overwrite, db_ml_models, db_run_list,
args.clean)

if __name__ == '__main__':
main()
7 changes: 4 additions & 3 deletions machine_learning_hep/templates_xgboost.py
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 ##
Expand All @@ -25,7 +25,7 @@

def xgboost_classifier(model_config): # pylint: disable=W0613
return XGBClassifier(verbosity=1,
n_gpus=0,
# n_gpus=0,
**model_config)


Expand Down Expand Up @@ -55,7 +55,8 @@ def yield_model_(self, model_config, space):

def save_model_(self, model, out_dir):
out_filename = join(out_dir, "xgboost_classifier.sav")
pickle.dump(model, open(out_filename, 'wb'), protocol=4)
with open(out_filename, 'wb') as outfile:
pickle.dump(model, outfile, protocol=4)
out_filename = join(out_dir, "xgboost_classifier.model")
model.save_model(out_filename)

Expand Down

0 comments on commit 9b2d0ea

Please sign in to comment.