21 from skopt.space
import Real, Integer
22 from sklearn.externals.joblib
import Parallel, delayed
23 import matplotlib.pyplot
as plt
27 """Returns the figure of merit for the optimization.
28 The functions trains the classifier with the given hyperparamters on the training sample and
29 calculates the AUC on the independet test sample.
31 g_options = general_options
32 g_options.m_identifier =
"test.xml"
33 options = basf2_mva.FastBDTOptions()
34 options.m_nTrees = int(x[0])
35 options.m_nLevels = int(x[1])
36 basf2_mva.teacher(g_options, options)
38 p, t = m.apply_expert(test_data, general_options.m_treename)
42 if __name__ ==
"__main__":
44 training_data = basf2_mva.vector(
"train.root")
45 test_data = basf2_mva.vector(
"test.root")
47 general_options = basf2_mva.GeneralOptions()
48 general_options.m_datafiles = training_data
49 general_options.m_treename =
"tree"
50 general_options.m_variables = basf2_mva.vector(
'p',
'pz',
'daughter(0, kaonID)',
'chiProb',
'M')
51 general_options.m_target_variable =
"isSignal"
54 res = skopt.gp_minimize(f,
61 skopt.plots.plot_convergence(res)
62 plt.savefig(
'convergence.png')
63 skopt.plots.plot_evaluations(res)
64 plt.savefig(
'evaluations.png')
65 skopt.plots.plot_objective(res)
66 plt.savefig(
'objective.png')
69 skopt.dump(res,
'opt-result.pkl')