Skip to content
Snippets Groups Projects
Commit 9bac2351 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

MVAUtils/convertLGBMToRootTree: avoid defining function within loop

parent a4d4463b
No related branches found
No related tags found
29 merge requests!78241Draft: FPGATrackSim: GenScan code refactor,!78236Draft: Switching Streams https://its.cern.ch/jira/browse/ATR-27417,!78056AFP monitoring: new synchronization and cleaning,!78041AFP monitoring: new synchronization and cleaning,!77990Updating TRT chip masks for L1TRT trigger simulation - ATR-28372,!77733Draft: add new HLT NN JVT, augmented with additional tracking information,!77731Draft: Updates to ZDC reconstruction,!77728Draft: updates to ZDC reconstruction,!77522Draft: sTGC Pad Trigger Emulator,!76725ZdcNtuple: Fix cppcheck warning.,!76611L1CaloFEXByteStream: Fix out-of-bounds array accesses.,!76475Punchthrough AF3 implementation in FastG4,!76474Punchthrough AF3 implementation in FastG4,!76343Draft: MooTrackBuilder: Recalibrate NSW hits in refine method,!75729New implementation of ZDC nonlinear FADC correction.,!75703Draft: Update to HI han config for HLT jets,!75184Draft: Update file heavyions_run.config,!74430Draft: Fixing upper bound for Delayed Jet Triggers,!73963Changing the path of the histograms to "Expert" area,!73875updating ID ART reference plots,!73874AtlasCLHEP_RandomGenerators: Fix cppcheck warnings.,!73449Add muon detectors to DarkJetPEBTLA partial event building,!73343Draft: [TrigEgamma] Add photon ringer chains on bootstrap mechanism,!72336Fixed TRT calibration crash,!72176Draft: Improving L1TopoOnline chain that now gets no-empty plots. Activating it by default,!72012Draft: Separate JiveXMLConfig.py into Config files,!71876Fix MET trigger name in MissingETMonitoring,!71820Draft: Adding new TLA End-Of-Fill (EOF) chains and removing obsolete DIPZ chains,!71342MVAUtils/convertLGBMToRootTree: avoid defining function within loop
......@@ -336,6 +336,14 @@ def test_generic(booster, mvautils_predict, mva_utils, data_input):
return True
# helper for tree traversal
def _ff(tree, node_infos):
if "left_child" in tree:
node_infos.append((tree["split_feature"], tree["threshold"]))
_ff(tree["left_child"])
_ff(tree["right_child"])
def test_detail_event(booster, mva_utils, input_values):
logging.info("input values")
for ivar, input_value in enumerate(input_values):
......@@ -363,17 +371,11 @@ def test_detail_event(booster, mva_utils, input_values):
# dump the tree from lightgbm
node_infos = []
def ff(tree):
if "left_child" in tree:
node_infos.append((tree["split_feature"], tree["threshold"]))
ff(tree["left_child"])
ff(tree["right_child"])
ff(
booster.dump_model()["tree_info"][itree][
"tree_structure"
]
_ff(
booster.dump_model()["tree_info"][itree][
"tree_structure"
],
node_infos
)
# we now which tree is failing, check if this is
......@@ -495,16 +497,11 @@ def test_multiclass(booster, mva_utils, ntests=10000, test_file=None):
# due to input values very close to the threshold
# the problem is that lgbm is using double,
# while mva_utils is using float
def ff(tree):
if "left_child" in tree:
node_infos.append((tree["split_feature"], tree["threshold"]))
ff(tree["left_child"])
ff(tree["right_child"])
ff(
booster.dump_model()["tree_info"][itree * nclasses + isubtree][
"tree_structure"
]
_ff(
booster.dump_model()["tree_info"][itree * nclasses + isubtree][
"tree_structure"
],
node_infos
)
for node_info in node_infos:
value = input_values[node_info[0]]
......
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