# I'm getting only a single value from the EvaluateMVA() method in the TMVAClassificationApplication.C macro

**URL:** <https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112>\
**Category:** TMVA\
**Tags:** tree, tmva, root\
**Created:** [August 23, 2023, 9:16am UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112 "2023-08-23T09:16:58Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [August 23, 2023, 9:16am UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/1 "2023-08-23T09:16:59Z")

</div>

I am performing ML tasks. I first trained and tested multiple configurations of BDTs using the TMVAClassification.C macro but when I’m trying to run my model using the [TMVAClassificationApplication.C](https://root.cern/doc/master/TMVAClassificationApplication_8C.html) macro, I’m getting only 1 value for the entire dataset. I did make the necessary changes in the application macro.

```auto
 // --------------------------------------------------------------------------------------------------
      if (Use["BDT"]) histBdt1 ->Fill( reader->EvaluateMVA( "BDT-1 method" ) );
      if (Use["BDT"]) histBdt2 ->Fill( reader->EvaluateMVA( "BDT-2 method" ) );
      if (Use["BDT"]) histBdt3 ->Fill( reader->EvaluateMVA( "BDT-3 method" ) );

      if (Use["BDTG"]) histBdtG1 ->Fill( reader->EvaluateMVA( "BDTG-1 method" ) );
      if (Use["BDTG"]) histBdtG2 ->Fill( reader->EvaluateMVA( "BDTG-2 method" ) );
      if (Use["BDTG"]) histBdtG3 ->Fill( reader->EvaluateMVA( "BDTG-3 method" ) );
      // --------------------------------------------------------------------------------------------------

```

I think there’s some problem with filling the trees. I’m attaching the macro and the data file.

[TMVAClassificationApplication.C](https://root-forum.cern.ch/uploads/short-url/uk5xVRPVJzZadfjEV63IJHx1gtZ.C) (23.5 KB)  
[Data\_90k.root](https://root-forum.cern.ch/uploads/short-url/np3HfsDdF6lQnyWHEKhztNgyEfP.root) (1.7 MB)

---

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [August 23, 2023, 9:18am UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/2 "2023-08-23T09:18:00Z")

</div>

The weight files are as follows:

[TMVAClassification\_BDT-2.class.C](https://root-forum.cern.ch/uploads/short-url/oP8qjK6YLhv1DIhD6Bjnwt50xHk.C) (396.5 KB)  
[TMVAClassification\_BDT-3.class.C](https://root-forum.cern.ch/uploads/short-url/7HXzUcTOw0FjP0OArdPUJv2FWfC.C) (567.3 KB)  
[TMVAClassification\_BDTG-1.class.C](https://root-forum.cern.ch/uploads/short-url/AtFZTodRUnms64aQvbXrBG9LW1K.C) (1.4 MB)  
[TMVAClassification\_BDTG-2.class.C](https://root-forum.cern.ch/uploads/short-url/rmQ4LYQtUu0NuVtkENAmqkDFj2r.C) (390.8 KB)  
[TMVAClassification\_BDTG-3.class.C](https://root-forum.cern.ch/uploads/short-url/s1s0iswPGGcL0MP4ISkoJ7QkvCV.C) (732.2 KB)

---

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [August 23, 2023, 9:18am UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/3 "2023-08-23T09:18:24Z")

</div>

[TMVAClassification\_BDT-1.class.C](https://root-forum.cern.ch/uploads/short-url/lszGtgNqpT0eH1Z6evX1CNzpt30.C) (450.9 KB)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [August 23, 2023, 10:28am UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/4 "2023-08-23T10:28:47Z")

</div>

Welcome to the ROOT forum

I guess @moneta can 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:** [August 25, 2023, 12:47pm UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/5 "2023-08-25T12:47:38Z")

</div>

Hi,  
For running your code I would need the `.xml` files for the weigths. The .C files are to be used to evaluate the method in a standalone C++ code. See for example the TMVA Users Guide paragraph 3.4.

Lorenzo

---

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [August 25, 2023, 1:19pm UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/6 "2023-08-25T13:19:24Z")

</div>

Sir I’m sending the files individually since ROOT Forum doesn’t allow .xml files

(Attachment TMVAClassification\_BDT-1.weights.xml is missing)

---

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [August 25, 2023, 1:20pm UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/7 "2023-08-25T13:20:37Z")

</div>

(Attachment TMVAClassification\_BDTG-2.weights.xml is missing)

---

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [August 25, 2023, 1:24pm UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/8 "2023-08-25T13:24:55Z")

</div>

ROOT isn’t allowing me to send.XML files. Can you please suggest me how can I send them to 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:** [August 25, 2023, 2:21pm UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/9 "2023-08-25T14:21:06Z")

</div>

You can try making a tar file with the xml file and upload the tar file, otherwise you can put on some share drive, like dropbox or cernbox or you can try directly by email

Lorenzo

---

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [August 25, 2023, 2:46pm UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/10 "2023-08-25T14:46:47Z")

</div>

Sir, here is the zip file. Zip was the default format. I really appreciate your help.

Kind regards  
Raktim

(Attachment weights.zip is missing)

---

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [August 25, 2023, 3:02pm UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/11 "2023-08-25T15:02:05Z")

</div>

Sir, here is the link containing the zip as well as the tar file. Zip was the default format. I really appreciate your help.  
[https://drive.google.com/drive/folders/13vhcb5E9MaxsEVT0J-ge2wMFEwVewNDd](https://drive.google.com/drive/folders/13vhcb5E9MaxsEVT0J-ge2wMFEwVewNDd)

Kind regards

Raktim

---

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [August 28, 2023, 7:26am UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/12 "2023-08-28T07:26:08Z")

</div>

Hi Mr. Moneta! Just wanted to follow up with my query.

---

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [September 4, 2023, 12:29pm UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/13 "2023-09-04T12:29:07Z")

</div>

Hi Mr. Moneta! Just wanted to follow up with my query. It would be really helpful if you could help me out ASAP since I need to submit my abstract this week.

Cheers!

---

<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:** [September 4, 2023, 1:51pm UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/14 "2023-09-04T13:51:09Z")

</div>

Hi,

There is a problem reading the input variables form the input file, since they are not stored as floating type variables. You need to convert to float before evaluating the method and set the correct type in `TTree::SetBranchAddress`. See my modified macro (you might want to remove some of the debug printout).  
I see still a potential issue that the file will contains many inputs equal for many events and this will result in same output values.

Apologies for my delay in answering,  
Best regards

Lorenzo  
[TMVAClassificationApplication.C](https://root-forum.cern.ch/uploads/short-url/wkiAO5mgcdy0Pxix9qxfCslsQXH.C) (24.0 KB)

---

<div class="post-metadata">

**Author:** ![Raktim\_Mukherjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raktim_mukherjee/32/31227_2.png) [@Raktim\_Mukherjee](https://root-forum.cern.ch/u/Raktim_Mukherjee)\
**Post date:** [September 4, 2023, 3:01pm UTC](https://root-forum.cern.ch/t/im-getting-only-a-single-value-from-the-evaluatemva-method-in-the-tmvaclassificationapplication-c-macro/56112/15 "2023-09-04T15:01:25Z")

</div>

Thank you Mr. Moneta. Your modification indeed solved the problem. Can’t thank you enough.😄
