136 def __init__(self, identifier):
138 Load a method stored under the given identifier
139 @param identifier identifying the method
144 ROOT.Belle2.MVA.AbstractInterface.initSupportedInterfaces()
146 self.identifier = identifier
148 self.weightfile = ROOT.Belle2.MVA.Weightfile.load(self.identifier)
150 self.general_options = basf2_mva.GeneralOptions()
151 self.general_options.load(self.weightfile.getXMLTree())
164 self.specific_options =
None
165 if self.general_options.m_method ==
"FastBDT":
166 self.specific_options = basf2_mva.FastBDTOptions()
167 elif self.general_options.m_method ==
"TMVAClassification":
168 self.specific_options = basf2_mva.TMVAOptionsClassification()
169 elif self.general_options.m_method ==
"TMVARegression":
170 self.specific_options = basf2_mva.TMVAOptionsRegression()
171 elif self.general_options.m_method ==
"FANN":
172 self.specific_options = basf2_mva.FANNOptions()
173 elif self.general_options.m_method ==
"Python":
174 self.specific_options = basf2_mva.PythonOptions()
175 elif self.general_options.m_method ==
"PDF":
176 self.specific_options = basf2_mva.PDFOptions()
177 elif self.general_options.m_method ==
"Combination":
178 self.specific_options = basf2_mva.CombinationOptions()
179 elif self.general_options.m_method ==
"Reweighter":
180 self.specific_options = basf2_mva.ReweighterOptions()
181 elif self.general_options.m_method ==
"Trivial":
182 self.specific_options = basf2_mva.TrivialOptions()
184 raise RuntimeError(
"Unknown method " + self.general_options.m_method)
186 self.specific_options.load(self.weightfile.getXMLTree())
188 variables = [str(v)
for v
in self.general_options.m_variables]
189 importances = self.weightfile.getFeatureImportance()
192 self.importances = {k: importances[k]
for k
in variables}
194 self.variables = list(sorted(variables, key=
lambda v: self.importances.get(v, 0.0)))
196 self.root_variables = [ROOT.Belle2.MakeROOTCompatible.makeROOTCompatible(v)
for v
in self.variables]
198 self.root_importances = {k: importances[k]
for k
in self.root_variables}
200 self.description = str(basf2_mva.info(self.identifier))
202 self.spectators = [str(v)
for v
in self.general_options.m_spectators]
204 self.root_spectators = [ROOT.Belle2.MakeROOTCompatible.makeROOTCompatible(v)
for v
in self.spectators]