Home | News | Documentation | Download

Issue with columns added to RDataFrame using experimental RReader and Compute within pyROOT

Dear experts,

I am trying to load an existing TMVA BDT model using pyROOT and compute the BDT scores using columns from a RDataFrame as inputs and add the output as a column. I followed the answer by @swunsch in RDataFrame and TMVA in pyroot and managed to add a column using TMVA::Experimental::RReader and TMVA::Experimental::Compute. However, it appears that it is not possible to use this column in a more complicated expression to make another column.

gInterpreter.ProcessLine('TMVA::Experimental::RReader model("%s");'%(xmlfile))
nBDTVars = len(ROOT.model.GetVariableNames())
gInterpreter.ProcessLine("computeModel = TMVA::Experimental::Compute<%d, float>(model);"%(nBDTVars))
DF = DF.Define("newbdt", ROOT.computeModel, ROOT.model.GetVariableNames())

Now if I do DF.Histo1D("newbdt") it works normally.

However, if I perform a simple arithmetic operation, such as DF.Define("newbdt2","newbdt+1") I get the following error:

input_line_169:2:35: error: invalid operands to binary expression ('__rdf1::newbdt5_type' (aka 'vector<float>') and 'int') 
return newbdt+1

note: candidate function not viable: no known conversion from '__rdf1::newbdt5_type' (aka 'vector<float>') to 'TString' for 1st argument
operator+(TString s, T i)

followed by several lines of similar errors.

I understand this is an experimental feature and I was wondering if it has been reported already. If so, is there a known workaround, or am I doing something wrong?

Thanks,
Spandan

ROOT Version: 6.20/01
Platform: EL7

Hi!

The inference returns a vector<float> because you could have more than a single output node for the model. So put a newbdt[0] +1 as expression and you are good to go!

Best
Stefan

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.