3 from ROOT
import TMVA, TFile, TString
4 from array
import array
5 from subprocess
import call
6 from os.path
import isfile
14 if not isfile(
'tmva_class_example.root'):
15 call([
'curl',
'-O',
'http://root.cern.ch/files/tmva_class_example.root'])
18 signal = data.Get(
'TreeS')
19 background = data.Get(
'TreeB')
22 for 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])
30 reader.BookMVA(
'PyKeras', TString(
'dataset/weights/TMVAClassification_PyKeras.weights.xml'))
33 print(
'Some signal example classifications:')
36 print(reader.EvaluateMVA(
'PyKeras'))
39 print(
'Some background example classifications:')
41 background.GetEntry(i)
42 print(reader.EvaluateMVA(
'PyKeras'))
static void PyInitialize()
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.