# How to apply TMVA classifier to the \*.root samples for analysis?

**URL:** <https://root-forum.cern.ch/t/how-to-apply-tmva-classifier-to-the-root-samples-for-analysis/31096>\
**Category:** TMVA\
**Created:** [October 12, 2018, 5:30pm UTC](https://root-forum.cern.ch/t/how-to-apply-tmva-classifier-to-the-root-samples-for-analysis/31096 "2018-10-12T17:30:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hepex001](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/f9ae1b/32.png) [@hepex001](https://root-forum.cern.ch/u/hepex001)\
**Post date:** [October 12, 2018, 5:30pm UTC](https://root-forum.cern.ch/t/how-to-apply-tmva-classifier-to-the-root-samples-for-analysis/31096/1 "2018-10-12T17:30:07Z")

</div>

Dear Experts,

I am quite new in TMVA.  
Using the tutorial TMVAClassification.C I am able to train and test the TMVA Classifier.  
Now I want to apply TMVA classifier to the \*.root samples for analysis, so that I will have TMVA classifier output as one of the leaf together with all other leafs in that \*.root file. I see there is an example TMVAClassificationApplication.C, but it just gives the output.

Please help me.  
Thanks.  
-A

---

<div class="post-metadata">

**Author:** ![kialbert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kialbert/32/16537_2.png) [@kialbert](https://root-forum.cern.ch/u/kialbert)\
**Post date:** [October 13, 2018, 8:16pm UTC](https://root-forum.cern.ch/t/how-to-apply-tmva-classifier-to-the-root-samples-for-analysis/31096/2 "2018-10-13T20:16:25Z")

</div>

Hi,

Please, do note that the input data is included in the TMVA output file as branches `TrainTree` and `TestTree` for training and test data respectively.

If you want to copy some object from one root file to another you can use the tool `rootcp`.

```auto
rootcp source.root:MethodBDT/BDT1 dest.root:BDTOutput

```

Would move all output for the BDT classifier named BDT1 to whatever rootfile `dest` represents.

If your input is spread of several files and you want to associate only a select part of the output file with each input file you could use `rooteventselector` which is a `rootcp` specifically for TTrees with extra functionality. Use e.g.

```auto
rooteventselector -f 0 -l 10000 source.root:tree dest.root

```

to copy the first 10000 entries in the TTree `tree` from file `source.root` to file `dest.root`. Use `rooteventselector --help` for more information.

Doing this in code instead of command line tools is possible, you’d have to create the tree structure yourself, but a bit involved. If you’d want to investigate this approach we can continue the discussion.

Cheers,  
Kim
