# Weights in TMVA

**URL:** <https://root-forum.cern.ch/t/weights-in-tmva/49706>\
**Category:** Newbie\
**Created:** [April 23, 2022, 4:14am UTC](https://root-forum.cern.ch/t/weights-in-tmva/49706 "2022-04-23T04:14:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JunKai](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/junkai/32/27450_2.png) [@JunKai](https://root-forum.cern.ch/u/JunKai)\
**Post date:** [April 23, 2022, 4:14am UTC](https://root-forum.cern.ch/t/weights-in-tmva/49706/1 "2022-04-23T04:14:30Z")

</div>

I am doing a binary classification with BDT (AdaBoost) from TMVA.  
I have S/B events in equal amount (say 1M each) for the training.  
But in the simulation data, S/B are actually in the ratio of 1/9.  
In order for the trained model to reflect this S/B distribution, do the following 3 methods work?

method 1: with equal amount of S/B, use weights  
factory-\>AddBackgroundTree(SigTree, 1.0);  
factory-\>AddBackgroundTree(BkgTree, 9.0);

method 2:  
reselect the events from S/B tree so that they have the correct proportion  
but this ends up with imbalanced data, doesnt it ?

method 3:  
reselect the events from S/B tree so that they have the correct proportion.  
then use weights  
factory-\>AddBackgroundTree(SigTree, 1.0);  
factory-\>AddBackgroundTree(BkgTree, 9.0);

btw, I am also not quite understand how to use these weights. could somebody explain to me ?

* * *

Thanks in advance

\_ROOT Version: 6.24 (PyROOT via conda)  
\_Platform:Centos7  
\_Compiler: gcc9

---

<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 26, 2022, 10:47am UTC](https://root-forum.cern.ch/t/weights-in-tmva/49706/2 "2022-04-26T10:47:05Z")

</div>

Hi,  
I am not sure I have understood correctly your questions. What do you mean with in the simulation data, S/B are actually in the ratio of 1/9 ? Is this the actual ration expected in the real data reflecting the different production cross section and selection ?

For the training you should use the maximum statistics available, you can use method1 but if you have a single background, it will not matter.  
Then for finding the optimal selection efficiency, you should maximise a metric, for example `S/sqrt(S+B)`, given the expected number of events in the data.

Cheers

Lorenzo
