# Converting .bin format model to .xml or .root format

**URL:** <https://root-forum.cern.ch/t/converting-bin-format-model-to-xml-or-root-format/59345>\
**Category:** TMVA\
**Tags:** root\
**Created:** [May 15, 2024, 9:24am UTC](https://root-forum.cern.ch/t/converting-bin-format-model-to-xml-or-root-format/59345 "2024-05-15T09:24:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![setesami](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/setesami/32/26795_2.png) [@setesami](https://root-forum.cern.ch/u/setesami)\
**Post date:** [May 15, 2024, 9:24am UTC](https://root-forum.cern.ch/t/converting-bin-format-model-to-xml-or-root-format/59345/1 "2024-05-15T09:24:27Z")

</div>

Dear Experts,

I have already trained models with xgboost package in binary format( .bin) and I want to convert it to root or xml format in order to be used to evaluate in TMVA. Is there any convertor or an example of how to convert it?

Thanks a lot  
Mohsen

---

<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:** [May 15, 2024, 1:00pm UTC](https://root-forum.cern.ch/t/converting-bin-format-model-to-xml-or-root-format/59345/2 "2024-05-15T13:00:41Z")

</div>

Hi,

Adding @lmoneta in the loop.

Best,  
D

---

<div class="post-metadata">

**Author:** ![setesami](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/setesami/32/26795_2.png) [@setesami](https://root-forum.cern.ch/u/setesami)\
**Post date:** [May 16, 2024, 1:11pm UTC](https://root-forum.cern.ch/t/converting-bin-format-model-to-xml-or-root-format/59345/3 "2024-05-16T13:11:41Z")

</div>

I also find this instruction from

> **[CHEP\_2019\_\_Machine\_Learning\_with\_ROOT\_TMVA.pdf](https://indico.cern.ch/event/773049/contributions/3476171/attachments/1936050/3208338/CHEP_2019__Machine_Learning_with_ROOT_TMVA.pdf)**

import ROOT  
import xgboost as xgb  
ele =xgb.Booster()  
ele.load\_model(‘my\_XGB.weights.bin’)  
ROOT.TMVA.SaveXGBoost(ele, “myBDT”, “model.root”)

But it seems the last command is not working and giving the following error

Traceback (most recent call last):  
File “”, line 1, in   
AttributeError: \<namespace cppyy.gbl.TMVA at 0x12f8fea60\> has no attribute ‘SaveXGBoost’. Full details:  
type object ‘TMVA’ has no attribute ‘SaveXGBoost’  
‘TMVA::SaveXGBoost’ is not a known C++ class  
‘SaveXGBoost’ is not a known C++ template  
‘SaveXGBoost’ is not a known C++ enum

Is SaveXGBoost already implemented or this is something under development?

Best  
Mohsen

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [May 17, 2024, 9:01am UTC](https://root-forum.cern.ch/t/converting-bin-format-model-to-xml-or-root-format/59345/4 "2024-05-17T09:01:19Z")

</div>

It is already implemented, but currently doesn’t work well.

It will be fixed in the upcoming ROOT 6.32.00 by replacing the internals with the FastForest library.

See:

- [[TMVA] Fix RBDT evaluation of XGBoost models by merging RBDT with FastForest by guitargeek · Pull Request #15173 · root-project/root · GitHub](https://github.com/root-project/root/pull/15173)
- [GitHub - setesami/XGBoost-FastForest: Minimal library code to deploy XGBoost models in C++.](https://github.com/setesami/XGBoost-FastForest)

---

<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:** [May 20, 2024, 4:38am UTC](https://root-forum.cern.ch/t/converting-bin-format-model-to-xml-or-root-format/59345/5 "2024-05-20T04:38:10Z")

</div>

Just to add to the post above, which I fully support: 6.32.00 is due at the end of the month. For the moment only the [Release Candidate](https://github.com/root-project/root/releases/tag/v6-32-00-rc1) is available.

Cheers,  
D
