RDataFrame and TMVA in pyroot

Hi!

Happy to see that you found the new feature :slight_smile: Though the disclaimer comes first: You are on experimental terrain!

Now the solution to your issue. Unfortunately, PyROOT (so the Python bindings for C++) are not (yet) able to parse the template we use in C++ (see here). However, you can play a little trick to make it still working in Python! Because PyROOT sees all objects created by the C++ interpreter cling, you can just make a call in C++. Please note that the snipplet assumes that you have run the tutorial tmva103_RReader.C before:

import ROOT

ROOT.gInterpreter.ProcessLine('''
TMVA::Experimental::RReader model("tmva003_BDT/weights/tmva003_BDT.weights.xml");
computeModel = TMVA::Experimental::Compute<4, float>(model);
''')

df = ROOT.RDataFrame('TreeS', 'http://root.cern.ch/files/tmva_class_example.root')
df = df.Define('y', ROOT.computeModel, ROOT.model.GetVariableNames())
h = df.Histo1D('y')

h.Draw()

Best
Stefan

3 Likes