11from ROOT
import TMVA, TFile, TString, gROOT
12from array
import array
13from subprocess
import call
14from os.path
import isfile
22data =
TFile.Open(str(gROOT.GetTutorialDir()) +
"/machine_learning/data/tmva_class_example.root")
23signal = data.Get(
'TreeS')
24background = data.Get(
'TreeB')
27for branch
in signal.GetListOfBranches():
28 branchName = branch.GetName()
29 branches[branchName] = array(
'f', [-999])
30 reader.AddVariable(branchName, branches[branchName])
31 signal.SetBranchAddress(branchName, branches[branchName])
32 background.SetBranchAddress(branchName, branches[branchName])
35reader.BookMVA(
'PyKeras',
TString(
'dataset/weights/TMVAClassification_PyKeras.weights.xml'))
38print(
'Some signal example classifications:')
41 print(reader.EvaluateMVA(
'PyKeras'))
44print(
'Some background example classifications:')
46 background.GetEntry(i)
47 print(reader.EvaluateMVA(
'PyKeras'))
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, 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.