# Usage of Category method

**URL:** <https://root-forum.cern.ch/t/usage-of-category-method/44591>\
**Category:** TMVA\
**Created:** [April 26, 2021, 12:55pm UTC](https://root-forum.cern.ch/t/usage-of-category-method/44591 "2021-04-26T12:55:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_Alici](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/andrea_alici/32/23695_2.png) [@Andrea\_Alici](https://root-forum.cern.ch/u/Andrea_Alici)\
**Post date:** [April 26, 2021, 12:55pm UTC](https://root-forum.cern.ch/t/usage-of-category-method/44591/1 "2021-04-26T12:55:34Z")

</div>

Dear TMVA experts,

I’m trying to run the BDT classification with 12 variables. In a subsample of events, 3 out of the 12 variables are missing and are assigned a default value = -9999 no matters if it is a signal or a background event. Even if the BDT looks working pretty nicely, it seems to me a perfect case where the usage of the category method could improve the classification (or at least I would expect a non-worse behavior).  
I tried to implement the classification with the category method but I’m a bit perplex about the results. I attach here the macro I used for the training, the output text file and the distributions of the BDT output classifier and a comparison of the ROC-curves. In particular the two-peak shape of the classifier distribution is quite worrisome to me.  
I’m wondering if I’m doing something wrong and in case how to implement correctly the procedure.  
Please let me know if I have to provide other information. The trees I’m using are quite huge but if needed I can select a subsample to test the macro.  
Thank you very much.  
Best regards,

andrea

 ![immagine](https://root-forum.cern.ch/uploads/default/original/3X/5/4/54a46e0a3fe8f178643b9c55454622552bfa716a.png)

 ![immagine](https://root-forum.cern.ch/uploads/default/original/3X/d/0/d05cfb6acefe379b625bf615947031350b791254.png)

[TMVAClassificationCategory.C](https://root-forum.cern.ch/uploads/short-url/ilagT23gHDNn4VInq0Gge9ZgLkn.C) (13.1 KB)

[TMVACategory\_output\_0\_1\_12.txt](https://root-forum.cern.ch/uploads/short-url/afMhNJE4xc2T1VdajwU1vFG2a1j.txt) (49.0 KB)

---

<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:** [April 27, 2021, 7:21am UTC](https://root-forum.cern.ch/t/usage-of-category-method/44591/2 "2021-04-27T07:21:07Z")

</div>

Hi @Andrea_Alici,

I am inviting @moneta to this topic. I am sure he can help you with this.

Cheers,  
Javier.

---

<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:** [April 28, 2021, 9:05am UTC](https://root-forum.cern.ch/t/usage-of-category-method/44591/3 "2021-04-28T09:05:46Z")

</div>

Hi Andrea,

Your macro seems correct to me. At first sight, it seems correct to me. It is an interesting case, I would need to get access to your trees to understand what is happening. If you could share them, for example on cernbox, I could have a look,

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![Andrea\_Alici](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/andrea_alici/32/23695_2.png) [@Andrea\_Alici](https://root-forum.cern.ch/u/Andrea_Alici)\
**Post date:** [April 28, 2021, 12:27pm UTC](https://root-forum.cern.ch/t/usage-of-category-method/44591/4 "2021-04-28T12:27:17Z")

</div>

Hi Lorenzo,

thanks a lot. I put here ([CERNBox](https://cernbox.cern.ch/index.php/s/swGy8Ii08Jus93e)) the trees for signal and background, it would be great if you could have a look at it.  
Cheers,

andrea

---

<div class="post-metadata">

**Author:** ![Andrea\_Alici](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/andrea_alici/32/23695_2.png) [@Andrea\_Alici](https://root-forum.cern.ch/u/Andrea_Alici)\
**Post date:** [April 29, 2021, 8:13am UTC](https://root-forum.cern.ch/t/usage-of-category-method/44591/5 "2021-04-29T08:13:31Z")

</div>

Hi Lorenzo,

I forgot to tell you that the distributions I posted at the beginning of the thread are obtained with TMVAClassificationCategory(1,2,“BDT”,1).  
Thanks a lot again.  
Cheers,

andrea

---

<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:** [April 30, 2021, 3:37pm UTC](https://root-forum.cern.ch/t/usage-of-category-method/44591/6 "2021-04-30T15:37:47Z")

</div>

Hi,  
I have tried your data, but I think your macro requires more data. Can you please send me a reduced version using only the data needed. Thanks

Lorenzo

---

<div class="post-metadata">

**Author:** ![Andrea\_Alici](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/andrea_alici/32/23695_2.png) [@Andrea\_Alici](https://root-forum.cern.ch/u/Andrea_Alici)\
**Post date:** [April 30, 2021, 4:52pm UTC](https://root-forum.cern.ch/t/usage-of-category-method/44591/7 "2021-04-30T16:52:35Z")

</div>

Hi Lorenzo,

sure, sorry for that. Attached here a version of the macro that works with the trees I put on the CERNbox.  
Thank you very much!  
Cheers,

andrea

[TMVAClassificationCategory.C](https://root-forum.cern.ch/uploads/short-url/eXBC33w4mDGqGsOaPKQZMER5ZFX.C) (10.7 KB)

---

<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:** [May 3, 2021, 8:49am UTC](https://root-forum.cern.ch/t/usage-of-category-method/44591/8 "2021-05-03T08:49:38Z")

</div>

Hi Andrea,

Thank you for the update of the macro. I could run it and I could reproduce results similar to yours, although the difference between NDT and BDTCat is less pronounced.  
Thinking about it, I think it makes sense to me that the performance of the single BDT are superior, because you are using more events for training trees. In the category case you are training separately two different methods, and in principle, if there are no real physical difference between the two cases, it is expected you will get worst performances.  
I think the category can be useful for some cases where there are some physical differences between the two category, for example angular region of a detector where you have in place a different type of detector with different resolution, in this case it is maybe better to not mix all the events together. Although I can expect that in several cases, the algorithm can learn the different itself, if they are well reproduced in the data.

Best regards

Lorenzo

---

<div class="post-metadata">

**Author:** ![Andrea\_Alici](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/andrea_alici/32/23695_2.png) [@Andrea\_Alici](https://root-forum.cern.ch/u/Andrea_Alici)\
**Post date:** [May 3, 2021, 9:38am UTC](https://root-forum.cern.ch/t/usage-of-category-method/44591/9 "2021-05-03T09:38:40Z")

</div>

Hi Lorenzo,

thank you very much for your reply!  
Indeed, the two categories refer to events which are completely similar from the physical point of view (and also from the point of view of detector’s resolution), the only difference is that due to dead areas and detector efficiency in a subsample of events some variables are not present, but apparently the BDT is able to handle this very satisfactorily. Your explanation is very reasonable, now it is more clear to me which are the cases where the usage of the category method could be useful.

Best regards,

andrea
