13from subprocess
import PIPE, run
16variables = [
'p',
'pz',
'daughter(0, p)',
'daughter(0, pz)',
'daughter(1, p)',
'daughter(1, pz)',
17 'chiProb',
'dr',
'dz',
'daughter(0, dr)',
'daughter(1, dr)',
'daughter(0, chiProb)',
'daughter(1, chiProb)',
18 'daughter(0, kaonID)',
'daughter(0, pionID)',
'daughterAngle(0, 1)']
20if __name__ ==
"__main__":
24 train_file = basf2.find_file(
'mva/train_D0toKpipi.root',
'examples',
False)
25 test_file = basf2.find_file(
'mva/test_D0toKpipi.root',
'examples',
False)
29 general_options = basf2_mva.GeneralOptions()
30 general_options.m_datafiles = basf2_mva.vector(train_file)
31 general_options.m_treename =
"tree"
32 general_options.m_variables = basf2_mva.vector(*variables)
33 general_options.m_target_variable =
"isSignal"
34 general_options.m_max_events = 200
37 (
'Trivial.xml', basf2_mva.TrivialOptions(),
None),
38 (
'FastBDT.xml', basf2_mva.FastBDTOptions(),
None),
39 (
'TMVAClassification.xml', basf2_mva.TMVAOptionsClassification(),
None),
40 (
'FANN.xml', basf2_mva.FANNOptions(),
None),
41 (
'Python_sklearn.xml', basf2_mva.PythonOptions(),
'sklearn'),
42 (
'Python_xgb.xml', basf2_mva.PythonOptions(),
'xgboost'),
43 (
'Python_tensorflow.xml', basf2_mva.PythonOptions(),
'tensorflow'),
44 (
'Python_torch.xml', basf2_mva.PythonOptions(),
'torch'),
49 for identifier, specific_options, framework
in methods:
50 general_options.m_identifier = identifier
51 if framework
is not None:
52 specific_options.m_framework = framework
53 basf2_mva.teacher(general_options, specific_options)
55 basf2_mva.expert(basf2_mva.vector(*[i
for i, _, _
in methods]),
56 basf2_mva.vector(train_file),
'tree',
'expert.root')
59 command = f
'basf2_mva_evaluate.py -o latex.pdf -train {train_file}'\
60 f
' -data {test_file} -i {" ".join([i for i, _, _ in methods])}'
63 stdout=PIPE, stderr=PIPE,
64 text=
True, shell=
True)
65 assert result.returncode == 0,
'basf2_mva_evaluate.py failed!'
def clean_working_directory()
def skip_test(reason, py_case=None)