Compute method problem with XGBoost-trained BDT in TMVA

I’m having problems with the model evaluation on a test set using the Compute(x) function of the ROOT.TMVA.Experimental.RBDT model. I’m strictly following the training at with a simple dataset of few variables.
This is the output I am given:

Training done on 9994 events. Saving model in tmva101.root
<class ‘numpy.ndarray’>
Traceback (most recent call last):
File “”, line 221, in
File “”, line 180, in main
y_pred = bdt.Compute(np.array(x) )
File “/home/apareti/sw/root/lib/ROOT/pythonization/”, line 30, in Compute
y = self.OriginalCompute(x)
TypeError: Template method resolution failed:
none of the 2 overloaded methods succeeded. Full details:
vector TMVA::Experimental::RBDT<TMVA::Experimental::BranchlessJittedForest >::Compute(const vector& x) =>
TypeError: could not convert argument 1
TMVA::Experimental::RTensor<float,vector > TMVA::Experimental::RBDT<TMVA::Experimental::BranchlessJittedForest >::Compute(const TMVA::Experimental::RTensor<float,vector >& x) =>
TypeError: could not convert argument 1
Failed to instantiate “Compute(TMVA::Experimental::RTensor<double,vector >&)”
Failed to instantiate “Compute(TMVA::Experimental::RTensor<double,vector >*)”
Failed to instantiate “Compute(TMVA::Experimental::RTensor<double,vector >)”

I’m using an Ubuntu 18.04.6 system, with ROOT version 6.24 and XGBoost 1.5.1.
Please let me know if any other information is required, and thanks a lot for the help,

Hi Andrea,

Welcome to the ROOT community!
Thanks for the post. I am sorry you are experiencing this issue: I am confident this can be fixed. For this reason, I add in the loop @moneta , responsible for ML/AI in ROOT.

Just for me to understand: does the tutorial work for you as is, or is a variation of it that produces the error?



I think it is an issue with the type of the numpy array you are passing to the Compute function.
Try doing:

y_pred = bdt.Compute(np.array(x, dtype='float32') )


1 Like

Hi @Danilo,
The only thing I changed in the tutorial process is the dataset (I’m using different variables, which are all floats). Apart from this I just copied the tutorial, since I wanted to learn using TMVA, and XGB is my go-to for simple classification tasks.

@moneta your suggestion worked just fine! Thank you very much.