# Convert XGBoost BDT regression model to TMVA

**URL:** <https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251>\
**Category:** TMVA\
**Created:** [May 4, 2020, 1:44pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251 "2020-05-04T13:44:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stepan\_Zakharov](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/stepan_zakharov/32/21842_2.png) [@Stepan\_Zakharov](https://root-forum.cern.ch/u/Stepan_Zakharov)\
**Post date:** [May 4, 2020, 1:44pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/1 "2020-05-04T13:44:41Z")

</div>

Hi, all!  
I’m looking for a way of conversion of the regression model trained with XGBoost into TMVA format.  
Before that, I tried to use this code [1], but there was a strange bug. The distribution of the regression output should be centered around 1 with the RMS value of 0.1. However, I get 0.5 bias of the mean value when applying the converted regression model on my dataset.  
ROOT version I’m using is 6.14.  
[1] [XGB2TMVA conversion code](https://gist.github.com/hqucms/56844f4d1e04757704f6afcdaa6f65a8)

Thanks for any help!  
Stepan.

---

<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:** [May 5, 2020, 9:02am UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/2 "2020-05-05T09:02:31Z")

</div>

Hi Stepan,

I don;t know about this conversion code, maybe @swunsch knows more. As indicated is probably a working version not fully tested yet.  
However, we have in ROOT a way to save trained XGBoost BDT in ROOT format and the read back to evaluate them , without going through the XML file, with a new fast inference engine.  
See the tutorials  
[https://root.cern.ch/doc/master/tmva101\_\_Training\_8py.html](https://root.cern.ch/doc/master/tmva101__Training_8py.html)

and  
[https://root.cern.ch/doc/master/tmva102\_\_Testing\_8py.html](https://root.cern.ch/doc/master/tmva102__Testing_8py.html)

Lorenzo

---

<div class="post-metadata">

**Author:** ![Stepan\_Zakharov](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/stepan_zakharov/32/21842_2.png) [@Stepan\_Zakharov](https://root-forum.cern.ch/u/Stepan_Zakharov)\
**Post date:** [May 5, 2020, 7:51pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/3 "2020-05-05T19:51:03Z")

</div>

Hi Lorenzo!  
Thank you for the quick response!  
I’ve installed ROOT 6.20 and checked this solution. Unfortunately, this didn’t have an effect. Here is the output of my program:

> Blockquote  
> Traceback (most recent call last):  
> File “MjjRegTrain.py”, line 106, in   
> main()  
> File “MjjRegTrain.py”, line 103, in main  
> train(params, train\_dataset, train\_dataset, ‘2017’)  
> File “MjjRegTrain.py”, line 62, in train  
> ROOT.TMVA.Experimental.SaveXGBoost(reg\_model, “myBDT”, “tmva101.root”)  
> TypeError: none of the 3 overloaded methods succeeded. Full details:  
> TMVA::Experimental::SaveXGBoost::TMVA::Experimental::SaveXGBoost() =\>  
> takes at most 0 arguments (3 given)  
> TMVA::Experimental::SaveXGBoost::TMVA::Experimental::SaveXGBoost(const TMVA::Experimental::SaveXGBoost&) =\>  
> takes at most 1 arguments (3 given)  
> TMVA::Experimental::SaveXGBoost::TMVA::Experimental::SaveXGBoost(TMVA::Experimental::SaveXGBoost&&) =\>  
> takes at most 1 arguments (3 given)

This looks like SaveXGBoost() has not yet been implemented at the master branch.  
Best,  
Stepan.

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [May 7, 2020, 7:13am UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/4 "2020-05-07T07:13:08Z")

</div>

Hi!

The feature is in 6.20, but you have to use PyROOT experimental (now becoming default in 6.22, release coming soonish). Then, you can run the tutorials that Lorenzo linked above! The requirements are xgboost\>=0.81 so that you can dump the model as a json file.  
Sry for the inconvenience, we still have the feature in experimental so it’s unfortunately not yet as accessible as it should be.

Best  
Stefan

---

<div class="post-metadata">

**Author:** ![Stepan\_Zakharov](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/stepan_zakharov/32/21842_2.png) [@Stepan\_Zakharov](https://root-forum.cern.ch/u/Stepan_Zakharov)\
**Post date:** [May 11, 2020, 4:33pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/5 "2020-05-11T16:33:08Z")

</div>

Dear Stefan,  
I reinstalled ROOT with PyROOT experimental. Then I tried to run the code Lorenzo shared with me. Looks like there is no module tmva100\_DataPreparation

> Traceback (most recent call last):  
> File “tmva\_train.py”, line 5, in   
> from tmva100\_DataPreparation import variables  
> File “/home/stepan/root-6-20/lib/python2.7/ROOT/\_facade.py”, line 80, in \_importhook  
> return \_orig\_ihook(name, \*args, \*\*kwds)  
> ImportError: No module named tmva100\_DataPreparation

While running my code I got the following error:

> Traceback (most recent call last):  
> File “MjjRegTrain.py”, line 106, in   
> main()  
> File “MjjRegTrain.py”, line 103, in main  
> train(params, train\_dataset, train\_dataset, ‘2017’)  
> File “MjjRegTrain.py”, line 62, in train  
> ROOT.TMVA.Experimental.SaveXGBoost(reg\_model, “BDTG”, “tmva101.root”)  
> File “/home/stepan/root-6-20/lib/python2.7/ROOT/pythonization/\_tree\_inference.py”, line 87, in SaveXGBoost  
> fill\_arrays(tree, 0, len\_inputs \* i\_tree, len\_thresholds \* i\_tree)  
> File "/home/stepan/root-6-20/lib/python2.7/ROOT/pythonization/_tree\_inference.py", line 70, in fill\_arrays  
> input_ = int(node[“split”].replace(“f”, “”))  
> ValueError: invalid literal for int() with base 10: ‘ttH\_MET’

where ttH\_MET is the first of my input variables. I’m using xgboost 0.82, so the part with saving of json files works ok.

Best,  
Stepan

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [May 11, 2020, 6:09pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/6 "2020-05-11T18:09:53Z")

</div>

Hi!

Regarding the failure here

> ImportError: No module named tmva100\_DataPreparation  
> I suppose you haven’t copied over the tmva100\_DataPreparation.py next to the `tmva_train.py` file? The training script just imports the variable names from the first tutorial.

Now about your second issue: Is it possible that you named your inputs in xgboost? We expect the features to be named `f<some number>` as they are by default. Probably you have done something like `xgboost.DMatrix(x, label=y, feature_names=labels)`? Unfortunately, that would not be supported with the experimental version.

Best  
Stefan

---

<div class="post-metadata">

**Author:** ![Stepan\_Zakharov](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/stepan_zakharov/32/21842_2.png) [@Stepan\_Zakharov](https://root-forum.cern.ch/u/Stepan_Zakharov)\
**Post date:** [May 12, 2020, 3:58pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/7 "2020-05-12T15:58:03Z")

</div>

Hi, Stefan!  
Thank you! I could successfully save XGB model into TMVA format. Then my question is about the format of the input dataset for the function bdt.Compute(x). Putting DataFrame object there, I get an error like this:

> 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(DataFrame)”

Am I correct that my input dataset should be converted into some different format like RTensor\<float,vector?

Best,  
Stepan.

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [May 12, 2020, 5:24pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/8 "2020-05-12T17:24:04Z")

</div>

Hi,

So the `Compute` function is like the `predict` in other frameworks, like sklearn or I think also xgboost. You can either put in your data as a `vector<float>`, a `RTensor<float>` or a `numpy.array`. However, if you want to inject the model prediction into an `RDataFrame`, you have to add it in a `Define` node. Actually, we have a tutorial for this [here](https://root.cern/doc/master/tmva103__Application_8C.html).

Further, if you want to do this from Python, we have currently the issue that the Python bindings break if you want to make the `TMVA::Experimental::Compute(model)` work. We just found this out in another forum thread, see [here](https://root-forum.cern.ch/t/rdataframe-and-tmva-in-pyroot/38930/2). There you find also the solution to this issue.

Best  
Stefan

---

<div class="post-metadata">

**Author:** ![Stepan\_Zakharov](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/stepan_zakharov/32/21842_2.png) [@Stepan\_Zakharov](https://root-forum.cern.ch/u/Stepan_Zakharov)\
**Post date:** [May 13, 2020, 5:53pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/9 "2020-05-13T17:53:15Z")

</div>

Dear Stefan,

Unfortunately, I didn’t manage to read .root file with BDT.  
I used the idea from [here](https://root-forum.cern.ch/t/rdataframe-and-tmva-in-pyroot/38930/2) and adapted it for bdt case. Before that, I checked [this example](https://root.cern.ch/doc/master/tmva103__Application_8C.html) The first two cases worked ok, so in general, I’m able to read files with the model.  
Here is the code I used for my model and dataset (all variables are renamed as f\_n, where n from 0 to 21).

> ROOT.gInterpreter.ProcessLine(‘’’  
> TMVA::Experimental::RBDT\<\> bdt(“BDTG”, “/home/stepan/Desktop/CMS/XGB2TMVA\_conv/tmva101.root”);  
> computeModel = TMVA::Experimental::Compute\<22, float\>(bdt);  
> ‘’')  
> df = ROOT.RDataFrame(‘bbggSelectionTree’, ‘/home/stepan/Desktop/CMS/XGB2TMVA\_conv/tmp.root’)  
> df = df.Define(‘y’, ROOT.computeModel,namelist)

While running, it throws TypeError:

> File “tmva\_mjj\_reg.py”, line 49, in mjj\_regresson\_TMVA  
> df = df.Define(‘y’, ROOT.computeModel,namelist)  
> TypeError: Template method resolution failed:  
> ROOT::RDF::RInterfaceROOT::Detail::RDF::RLoopManager,void ROOT::RDF::RInterfaceROOT::Detail::RDF::RLoopManager,void::Define(experimental::basic\_string\_view\<char,char\_traits \> name, experimental::basic\_string\_view\<char,char\_traits \> expression) =\>  
> TypeError: takes at most 2 arguments (3 given)  
> Failed to instantiate “Define(std::string,TMVA::Experimental::Internal::ComputeHelper\<integer\_sequence\<unsigned long,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21\>,float,TMVA::Experimental::RBDT\<TMVA::Experimental::BranchlessJittedForest \>&\>&,NoneType)”  
> Failed to instantiate “Define(std::string,TMVA::Experimental::Internal::ComputeHelper\<integer\_sequence\<unsigned long,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21\>,float,TMVA::Experimental::RBDT\<TMVA::Experimental::BranchlessJittedForest \>&\>\*,NoneType)”  
> Failed to instantiate “Define(std::string,TMVA::Experimental::Internal::ComputeHelper\<integer\_sequence\<unsigned long,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21\>,float,TMVA::Experimental::RBDT\<TMVA::Experimental::BranchlessJittedForest \>&\>,NoneType)”

I try to dig in the examples from the TMVA::Experimental code, but unable to find something useful.  
Any ideas?

Best,  
Stepan.

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [May 14, 2020, 7:27am UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/10 "2020-05-14T07:27:49Z")

</div>

Hi!

The output of PyROOT tells us that the `namelist` is resolved as `NoneType`, see here:  
`std::string, <the functor>, NoneType`

Is it a valid object?

Best  
Stefan

---

<div class="post-metadata">

**Author:** ![clementhelsens](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/clementhelsens/32/24840_2.png) [@clementhelsens](https://root-forum.cern.ch/u/clementhelsens)\
**Post date:** [March 28, 2021, 7:07pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/11 "2021-03-28T19:07:44Z")

</div>

@swunsch , if I may ask, are the python bindings now able to call Compute as expected?  
I see something like this here  
[https://fossies.org/linux/root/tmva/tmva/test/rbdt\_xgboost.py](https://fossies.org/linux/root/tmva/tmva/test/rbdt_xgboost.py)  
with root 6.22/08

Thanks,  
Clement

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [March 29, 2021, 6:58am UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/12 "2021-03-29T06:58:22Z")

</div>

Hi!

There was no major change in functionality. So the cases you linked (these are tests of RBDT against XGBoost), work as expected.

Could you specify what exactly you mean?

Best  
Stefan

---

<div class="post-metadata">

**Author:** ![clementhelsens](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/clementhelsens/32/24840_2.png) [@clementhelsens](https://root-forum.cern.ch/u/clementhelsens)\
**Post date:** [March 29, 2021, 7:10am UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/13 "2021-03-29T07:10:37Z")

</div>

Thanks for the reply @swunsch, I’m trying to find the easiest way to use in python RDF `Compute` on RDBT like done in C here:  
[https://root.cern/doc/master/tmva103\_\_Application\_8C.html](https://root.cern/doc/master/tmva103__Application_8C.html)

When trying with root 6.22/06  
`bdt = ROOT.TMVA.Experimental.RBDT["", "default"]("myBDT", "/eos/experiment/fcc/ee/analyses/case-studies/flavour/Bc2TauNu/xgb_bdt.root")`  
I get something like

```auto
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/cvmfs/sw.hsf.org/spackages/linux-centos7-broadwell/gcc-8.3.0/root-6.22.06-hjtu4d3lq6ltvm7nba47duznmj2f37ci/lib/cppyy/_cpython_cppyy.py", line 86, in __getitem__
    return self. __call__ (*(args[0]))
  File "/cvmfs/sw.hsf.org/spackages/linux-centos7-broadwell/gcc-8.3.0/root-6.22.06-hjtu4d3lq6ltvm7nba47duznmj2f37ci/lib/cppyy/_cpython_cppyy.py", line 67, in __call__
    pyclass = _backend.MakeCppTemplateClass(*newargs)
TypeError: 'TMVA::Experimental::RBDT<,default>' is not a known C++ class

```

so I am wondering if one should continue to use the trick through `gInterpreter`

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [March 29, 2021, 7:28am UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/14 "2021-03-29T07:28:40Z")

</div>

Ah alright! Unfortunately, the simplest solution for Python is a two-line helper function. You can find an example [here](https://root-forum.cern.ch/t/rdataframe-and-tmva-in-pyroot/38930/3).

Best,  
Stefan

---

<div class="post-metadata">

**Author:** ![clementhelsens](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/clementhelsens/32/24840_2.png) [@clementhelsens](https://root-forum.cern.ch/u/clementhelsens)\
**Post date:** [March 29, 2021, 8:44am UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/15 "2021-03-29T08:44:25Z")

</div>

thanks @swunsch.  
Here is what I’m trying:

```auto
ROOT.gInterpreter.ProcessLine('''
TMVA::Experimental::RBDT<> bdt("Bc2TauNu_BDT", "/eos/experiment/fcc/ee/analyses/case-studies/flavour/Bc2TauNu/xgb_bdt.root");
computeModel = TMVA::Experimental::Compute<10, float>(bdt);
''')

```

and the RDF call:

```auto
.Define("MVA", ROOT.computeModel, {"EVT_thrutshemis_e_min", "EVT_thrutshemis_e_max", "EVT_Echarged_min", "EVT_Echarged_max", "EVT_Eneutral_min", "EVT_Eneutral_max", "EVT_Ncharged_min", "EVT_Ncharged_max", "EVT_Nneutral_min", "EVT_Nneutral_max"})

```

but I see a similar problem as reported earlier:

```auto
  File "examples/FCCee/flavour/Bc2TauNu/analysis_DV.py", line 101, in run
    .Define("MVA", ROOT.computeModel, {"EVT_thrutshemis_e_min", "EVT_thrutshemis_e_max", "EVT_Echarged_min", "EVT_Echarged_max", "EVT_Eneutral_min", "EVT_Eneutral_max", "EVT_Ncharged_min", "EVT_Ncharged_max", "EVT_Nneutral_min", "EVT_Nneutral_max"})
TypeError: Template method resolution failed:
  ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void> ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager,void>::Define(basic_string_view<char,char_traits<char> > name, basic_string_view<char,char_traits<char> > expression) =>
    TypeError: takes at most 2 arguments (3 given)
  Failed to instantiate "Define(std::string,TMVA::Experimental::Internal::ComputeHelper<integer_sequence<unsigned long,0,1,2,3,4,5,6,7,8,9>,float,TMVA::Experimental::RBDT<TMVA::Experimental::BranchlessJittedForest<float> >&>&,set)"
  Failed to instantiate "Define(std::string,TMVA::Experimental::Internal::ComputeHelper<integer_sequence<unsigned long,0,1,2,3,4,5,6,7,8,9>,float,TMVA::Experimental::RBDT<TMVA::Experimental::BranchlessJittedForest<float> >&>*,set)"
  Failed to instantiate "Define(std::string,TMVA::Experimental::Internal::ComputeHelper<integer_sequence<unsigned long,0,1,2,3,4,5,6,7,8,9>,float,TMVA::Experimental::RBDT<TMVA::Experimental::BranchlessJittedForest<float> >&>,set)"

```

any idea ?  
thanks  
Clement

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [March 30, 2021, 7:26am UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/16 "2021-03-30T07:26:39Z")

</div>

Hi!

I think the issue is that you put in a set as the last argument (in Python the `{'foo', 'bar', ...}`) rather than an array or list (use `['foo', 'bar', ...]` or `('foo', 'bar', ...)`). Try again like this:

```python
.Define("MVA", ROOT.computeModel, ("EVT_...", ...))

```

Best  
Stefan

---

<div class="post-metadata">

**Author:** ![clementhelsens](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/clementhelsens/32/24840_2.png) [@clementhelsens](https://root-forum.cern.ch/u/clementhelsens)\
**Post date:** [March 30, 2021, 12:09pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/17 "2021-03-30T12:09:36Z")

</div>

of course… thanks for spotting this python inconsistency @swunsch. Works as expected!  
Thanks for the feedback  
Clement

---

<div class="post-metadata">

**Author:** ![clementhelsens](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/clementhelsens/32/24840_2.png) [@clementhelsens](https://root-forum.cern.ch/u/clementhelsens)\
**Post date:** [May 12, 2021, 6:54pm UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/18 "2021-05-12T18:54:34Z")

</div>

Hello @swunsch ,

I get a massive seg fault when switching to ROOT v6.24.  
The way we save the BDT has changed, we need to add `num_inputs` like below

`ROOT.TMVA.Experimental.SaveXGBoost(bdt, "Bc2TauNu_BDT2", f"{out}/xgb_bdt_stage2.root", num_inputs=len(vars_list))`

but for the model evaluation, is there some changes in the syntax?  
Thanks,  
Clement

EDIT2

in plain python I can run this

```auto
import ROOT
ROOT.gInterpreter.ProcessLine('''
TMVA::Experimental::RBDT<> bdt("Bc2TauNu_BDT2", "/eos/experiment/fcc/ee/analyses/case-studies/flavour/Bc2TauNu/xgb_bdt_stage2.root");
computeModel = TMVA::Experimental::Compute<20, float>(bdt);
''')
toto=ROOT.computeModel(0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.)
print(toto.at(0))
5.371956035560288e-08

```

so it seems to come from the dataframe evaluation

```auto
               .Define("MVAVec", ROOT.computeModel, ("EVT_CandMass",
                                                     "EVT_CandRho1Mass",
                                                     "EVT_CandRho2Mass",
                                                     "EVT_CandN",
                                                     "EVT_CandVtxFD",
                                                     "EVT_CandVtxChi2",
                                                     "EVT_CandPx",
                                                     "EVT_CandPy",
                                                     "EVT_CandPz",
                                                     "EVT_CandP",
                                                     "EVT_CandD0",
                                                     "EVT_CandZ0",
                                                     "EVT_CandAngleThrust",
                                                     "EVT_DVd0_min",
                                                     "EVT_DVd0_max",
                                                     "EVT_DVd0_ave",
                                                     "EVT_DVz0_min",
                                                     "EVT_DVz0_max",
                                                     "EVT_DVz0_ave",
                                                     "EVT_Nominal_B_E"))

```

maybe @eguiraud has an idea?

---

<div class="post-metadata">

**Author:** ![clementhelsens](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/clementhelsens/32/24840_2.png) [@clementhelsens](https://root-forum.cern.ch/u/clementhelsens)\
**Post date:** [May 13, 2021, 8:08am UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/19 "2021-05-13T08:08:43Z")

</div>

Seems I was still having a variable defined as `double` rather than `float`  
sorry for the noise

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [May 17, 2021, 8:16am UTC](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251/20 "2021-05-17T08:16:56Z")

</div>

Hi @clementhelsens ,  
good that you found the solution! I would argue that it’s still not nice to crash without a human-readable error message because of a type mismatch, feel free to open a github issue about the problem (ideally with a self-container reproducer).

Cheers,  
Enrico

[Next page](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251.md?page=2)
