3from ROOT
import TMVA, TFile, TString
5from subprocess
import call
6from os.path
import isfile
14if not isfile(
'tmva_reg_example.root'):
15 call([
'curl',
'-O',
'http://root.cern.ch/files/tmva_reg_example.root'])
18tree = data.Get(
'TreeR')
21for 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])
29reader.BookMVA(
'PyKeras', TString(
'dataset/weights/TMVARegression_PyKeras.weights.xml'))
32print(
'Some example regressions:')
35 print(
'True/MVA value: {}/{}'.format(branches[
'fvalue'][0],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.