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_reg_example.root'):
15 call([
'curl',
'-O',
'http://root.cern.ch/files/tmva_reg_example.root'])
18 tree = data.Get(
'TreeR')
21 for branch
in tree.GetListOfBranches():
22 branchName = branch.GetName()
23 branches[branchName] = array(
'f', [-999])
24 tree.SetBranchAddress(branchName, branches[branchName])
25 if branchName !=
'fvalue':
26 reader.AddVariable(branchName, branches[branchName])
29 reader.BookMVA(
'PyKeras', TString(
'dataset/weights/TMVAClassification_PyKeras.weights.xml'))
32 print(
'Some example regressions:')
35 print(
'True/MVA value: {}/{}'.
format(branches[
'fvalue'][0],reader.EvaluateMVA(
'PyKeras')))
static std::string format(double x, double y, int digits, int width)
static void PyInitialize()
Initialize Python interpreter.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
The Reader class serves to use the MVAs in a specific analysis context.