# 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:** 1\
**Showing post:** 9

<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.

---

_[View the full topic](https://root-forum.cern.ch/t/convert-xgboost-bdt-regression-model-to-tmva/39251)._
