# TMVA Get Single Decision Tree From Forest

**URL:** <https://root-forum.cern.ch/t/tmva-get-single-decision-tree-from-forest/38546>\
**Category:** TMVA\
**Tags:** tmva\
**Created:** [March 23, 2020, 11:49pm UTC](https://root-forum.cern.ch/t/tmva-get-single-decision-tree-from-forest/38546 "2020-03-23T23:49:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Str55](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/str55/32/32911_2.png) [@Str55](https://root-forum.cern.ch/u/Str55)\
**Post date:** [March 23, 2020, 11:49pm UTC](https://root-forum.cern.ch/t/tmva-get-single-decision-tree-from-forest/38546/1 "2020-03-23T23:49:49Z")

</div>

Hello,

For a very specific application of boosted decision trees, I would like to, after training my classifier with many trees, evaluate an event with a single one of those trees. I have found no method built into TMVA to do this (for good reason, I can’t imagine anyone wanting to do this outside of my project).

I see that in line 2353 of MethodBDT.cxx, the way this is done is through

`fForest[itree]->CheckEvent(ev,fUseYesNoLeaf)`

This will work for me. My question then is how, given the xml weights file from my BDT, can I get the fForest vector so I can get a single tree object to do this to?

Thank you!

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [March 24, 2020, 7:30am UTC](https://root-forum.cern.ch/t/tmva-get-single-decision-tree-from-forest/38546/2 "2020-03-24T07:30:44Z")

</div>

I think @moneta can most probably help you

---

<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:** [March 24, 2020, 1:55pm UTC](https://root-forum.cern.ch/t/tmva-get-single-decision-tree-from-forest/38546/3 "2020-03-24T13:55:24Z")

</div>

Hi,

You should be able to call the `MethodBDT::GetForest()` function, which will return `fForest, a vector with all the trees.

To get the MethodBDT object, if you have an XML file you can use the function [Reader::BookMVA](https://root.cern.ch/doc/v606/classTMVA_1_1Reader.html#a9b12ddc2a1b307b1f5042e39ee73e067)

Lorenzo

---

<div class="post-metadata">

**Author:** ![Str55](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/str55/32/32911_2.png) [@Str55](https://root-forum.cern.ch/u/Str55)\
**Post date:** [March 24, 2020, 2:15pm UTC](https://root-forum.cern.ch/t/tmva-get-single-decision-tree-from-forest/38546/4 "2020-03-24T14:15:54Z")

</div>

Hi Lorenzo,

Thank you very much, this is exactly what I needed and works perfectly!

Best,  
Steve
