12 variables = [
'M',
'p',
'pt',
'pz',
13 'daughter(0, p)',
'daughter(0, pz)',
'daughter(0, pt)',
14 'daughter(1, p)',
'daughter(1, pz)',
'daughter(1, pt)',
15 'daughter(2, p)',
'daughter(2, pz)',
'daughter(2, pt)',
16 'chiProb',
'dr',
'dz',
17 'daughter(0, dr)',
'daughter(1, dr)',
18 'daughter(0, dz)',
'daughter(1, dz)',
19 'daughter(0, chiProb)',
'daughter(1, chiProb)',
'daughter(2, chiProb)',
20 'daughter(0, kaonID)',
'daughter(0, pionID)',
21 'daughterInvariantMass(0, 1)',
'daughterInvariantMass(0, 2)',
'daughterInvariantMass(1, 2)']
31 return np.require(p, dtype=np.float32, requirements=[
'A',
'W',
'C',
'O'])
34 def begin_fit(state, Xtest, Stest, ytest, wtest):
36 Test begin_fit function
38 print(Xtest.mean(axis=0))
39 print(Xtest.std(axis=0))
43 def partial_fit(state, X, S, y, w, epoch):
45 Test partial_fit function
52 print(
"Executed python script")
54 if __name__ ==
"__main__":
57 if not (os.path.isfile(
'train.root')
and os.path.isfile(
'test.root')):
58 print(
"TEST SKIPPED: Not runnable on build bot", file=sys.stderr)
61 general_options = basf2_mva.GeneralOptions()
62 general_options.m_datafiles = basf2_mva.vector(
"train.root")
63 general_options.m_treename =
"tree"
64 general_options.m_variables = basf2_mva.vector(*variables)
65 general_options.m_target_variable =
"isSignal"
66 general_options.m_identifier =
"Python.xml"
68 specific_options = basf2_mva.PythonOptions()
69 specific_options.m_training_fraction = 0.9
70 specific_options.m_nIterations = 1
71 specific_options.m_mini_batch_size = 0
72 specific_options.m_framework =
'test'
73 specific_options.m_steering_file =
'mva/tests/python_normalization.py'
74 specific_options.m_normalize =
False
77 with tempfile.TemporaryDirectory()
as tempdir:
78 os.symlink(os.path.abspath(
'train.root'), tempdir +
'/' + os.path.basename(
'train.root'))
81 basf2_mva.teacher(general_options, specific_options)
82 basf2_mva.expert(basf2_mva.vector(
"Python.xml"),
83 basf2_mva.vector(
'train.root'),
'tree',
'expert.root')
84 specific_options.m_normalize =
True
85 basf2_mva.teacher(general_options, specific_options)
86 basf2_mva.expert(basf2_mva.vector(
"Python.xml"),
87 basf2_mva.vector(
'train.root'),
'tree',
'expert.root')