# TMVA: the same samples, but very different results from traintest and apply phase using BDT or MLP

**URL:** <https://root-forum.cern.ch/t/tmva-the-same-samples-but-very-different-results-from-traintest-and-apply-phase-using-bdt-or-mlp/45827>\
**Category:** TMVA\
**Created:** [July 13, 2021, 12:25pm UTC](https://root-forum.cern.ch/t/tmva-the-same-samples-but-very-different-results-from-traintest-and-apply-phase-using-bdt-or-mlp/45827 "2021-07-13T12:25:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yi.yu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/ce7236/32.png) [@yi.yu](https://root-forum.cern.ch/u/yi.yu)\
**Post date:** [July 13, 2021, 12:25pm UTC](https://root-forum.cern.ch/t/tmva-the-same-samples-but-very-different-results-from-traintest-and-apply-phase-using-bdt-or-mlp/45827/1 "2021-07-13T12:25:11Z")

</div>

[YiMVA.zip](https://root-forum.cern.ch/uploads/short-url/esz2fZhmaLI8axJFL62uDGSHgdp.zip) (2.9 MB)  
Dear all,

I trained a BDT model,  
but when i used the weight file to apply for the same samples (used for train & test),  
the results are very different.

Could you help me with the situation?  
(please see the following figures, and the code and samples are also attached, thanks)

 ![BDTG_TrainTest_2v3](https://root-forum.cern.ch/uploads/default/original/3X/e/7/e7adff61fb12352a855ba84ad73935b536e1e6c9.png)  
 ![BDTG_App_c2030m1000](https://root-forum.cern.ch/uploads/default/original/3X/f/d/fde2c938d25c7fb6e3bcc34c66548907db60e50c.png)

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [July 13, 2021, 12:29pm UTC](https://root-forum.cern.ch/t/tmva-the-same-samples-but-very-different-results-from-traintest-and-apply-phase-using-bdt-or-mlp/45827/2 "2021-07-13T12:29:36Z")

</div>

Hi @yi.yu,

I am inviting @moneta to this topic as the relevant expert in TMVA. Unfortunately, I think he is off for a few days and might take a while to reply.

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![yi.yu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/ce7236/32.png) [@yi.yu](https://root-forum.cern.ch/u/yi.yu)\
**Post date:** [July 14, 2021, 5:19pm UTC](https://root-forum.cern.ch/t/tmva-the-same-samples-but-very-different-results-from-traintest-and-apply-phase-using-bdt-or-mlp/45827/3 "2021-07-14T17:19:36Z")

</div>

Hi @jalopezg and @moneta,

I find the TMVA User Guide wrote that only **int and float** are supported in the applying phase.  
so i try to change the double-branch to float-branch, such as “beta”, and comment the int-variables,  
the applying results get normal.

but when i try to use the int-variable, like “pixelHit”, the applying results get abnormal again, and the red errors appear as the following. (now i have change all type to float, and it runs smoothly)

hence, i wanna to know if the TMVA only supports the Float type, and what the meaning of the errors?

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/5/7/57cbdab73ce8b70310249ac8f0d32540a35d7496.png)

thanks,  
Yi

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [July 15, 2021, 1:54pm UTC](https://root-forum.cern.ch/t/tmva-the-same-samples-but-very-different-results-from-traintest-and-apply-phase-using-bdt-or-mlp/45827/4 "2021-07-15T13:54:26Z")

</div>

Hi @yi.yu,

Yes, according to the [TMVA guide](https://root.cern.ch/download/doc/tmva/TMVAUsersGuide.pdf), it supports integer and floating-point types.

I think that the problem is that you have to specify the type to be `I` (for integer) in your `TMVA::DataLoader::AddVariable()` calls (in files trainNew.py and addNew.py). See the doxygen documentation here: [ROOT: TMVA::DataLoader Class Reference](https://root.cern.ch/doc/v608/classTMVA_1_1DataLoader.html#af2de13debc441fd2c4f1cd826ef175f9). Note that, if unspecified by the user, it defaults to `F` (float).

Cheers,  
J.
