3from ROOT
import TMVA, TFile, TString
5from subprocess
import call
6from os.path
import isfile
14if not isfile(
'tmva_class_example.root'):
15 call([
'curl',
'-O',
'http://root.cern.ch/files/tmva_class_example.root'])
18signal = data.Get(
'TreeS')
19background = data.Get(
'TreeB')
22for branch
in signal.GetListOfBranches():
23 branchName = branch.GetName()
24 branches[branchName] = array(
'f', [-999])
25 reader.AddVariable(branchName, branches[branchName])
26 signal.SetBranchAddress(branchName, branches[branchName])
27 background.SetBranchAddress(branchName, branches[branchName])
30reader.BookMVA(
'PyKeras', TString(
'dataset/weights/TMVAClassification_PyKeras.weights.xml'))
33print(
'Some signal example classifications:')
36 print(reader.EvaluateMVA(
'PyKeras'))
39print(
'Some background example classifications:')
41 background.GetEntry(i)
42 print(reader.EvaluateMVA(
'PyKeras'))
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose, Int_t netopt=0)
Create / open a file.
static void PyInitialize()
Initialize Python interpreter.
The Reader class serves to use the MVAs in a specific analysis context.