# Compute method problem with XGBoost-trained BDT in TMVA

**URL:** <https://root-forum.cern.ch/t/compute-method-problem-with-xgboost-trained-bdt-in-tmva/57901>\
**Category:** TMVA\
**Tags:** python, rdataframe, root\
**Created:** [January 19, 2024, 10:38am UTC](https://root-forum.cern.ch/t/compute-method-problem-with-xgboost-trained-bdt-in-tmva/57901 "2024-01-19T10:38:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ANDREA\_PARETI](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/andrea_pareti/32/35494_2.png) [@ANDREA\_PARETI](https://root-forum.cern.ch/u/ANDREA_PARETI)\
**Post date:** [January 19, 2024, 10:38am UTC](https://root-forum.cern.ch/t/compute-method-problem-with-xgboost-trained-bdt-in-tmva/57901/1 "2024-01-19T10:38:58Z")

</div>

Hello,  
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  
root.cern/doc/master/tmva102\_\_Testing\_8py.html 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 “PiGammaSeparation.py”, line 221, in   
> main()  
> File “PiGammaSeparation.py”, line 180, in main  
> y\_pred = bdt.Compute(np.array(x) )  
> File “/home/apareti/sw/root/lib/ROOT/pythonization/\_rbdt.py”, 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,  
Andrea

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [January 21, 2024, 6:46am UTC](https://root-forum.cern.ch/t/compute-method-problem-with-xgboost-trained-bdt-in-tmva/57901/2 "2024-01-21T06:46:29Z")

</div>

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?

Cheers,  
Danilo

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [January 22, 2024, 8:28am UTC](https://root-forum.cern.ch/t/compute-method-problem-with-xgboost-trained-bdt-in-tmva/57901/3 "2024-01-22T08:28:43Z")

</div>

Hi,

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

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

```

Lorenzo

---

<div class="post-metadata">

**Author:** ![apareti](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/a88e57/32.png) [@apareti](https://root-forum.cern.ch/u/apareti)\
**Post date:** [January 22, 2024, 10:14am UTC](https://root-forum.cern.ch/t/compute-method-problem-with-xgboost-trained-bdt-in-tmva/57901/4 "2024-01-22T10:14:09Z")

</div>

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.

Andrea
