# Handling negative weight events with BDTG

**URL:** <https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373>\
**Category:** TMVA\
**Created:** [April 11, 2021, 5:01pm UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373 "2021-04-11T17:01:30Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![shankha\_banerjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shankha_banerjee/32/25531_2.png) [@shankha\_banerjee](https://root-forum.cern.ch/u/shankha_banerjee)\
**Post date:** [April 11, 2021, 5:01pm UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/1 "2021-04-11T17:01:30Z")

</div>

Hi,

I am dealing with an effective field theory scenario where my signal (the interference term) has almost equal proportion of negative and positive weight events. To try and train the samples, I was following this suggestion: [TMVA Toolkit for Multi Variate Analysis / Re: [TMVA-users] BDT training with negative weights.](https://sourceforge.net/p/tmva/mailman/message/34776028/), i.e., using the BDTG method and using the “Pray” option. However, I am getting the following error and am unable to train the samples.

: signal and background histograms have different or invalid dimensions:

I am attaching my code and the problematic root file required for the training.

I would greatly appreciate if you could guide me as to how I can train such samples properly.

Many thanks.

Best regards,

Shankha.[TMVAClassification\_ggH.C](https://root-forum.cern.ch/uploads/short-url/50lnQGTHQFIS9K9uAtnbliJn2EE.C) (6.8 KB) [Int\_kZZ\_OFFSHELL\_dghZZp05kZZp368572.root](https://root-forum.cern.ch/uploads/short-url/4V8EgKaozvYs1u5Xe3oYuPXwbCF.root) (2.9 MB)

---

<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 12, 2021, 12:56pm UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/2 "2021-04-12T12:56:44Z")

</div>

Hi,  
Thank you for sharing the files, I will try to reproduce your problem. However, I think if negative weighs dominates on the positive ones, this can be problematic because you end up with some statistics, like the input data variable variances being negative. This could be the cause of the errors you observe

Best regards

Lorenzo

---

<div class="post-metadata">

**Author:** ![shankha\_banerjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shankha_banerjee/32/25531_2.png) [@shankha\_banerjee](https://root-forum.cern.ch/u/shankha_banerjee)\
**Post date:** [April 12, 2021, 2:27pm UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/3 "2021-04-12T14:27:34Z")

</div>

Hi Lorenzo,

Many thanks. I understand the practical difficulty. However, for NLO samples as well as interference samples, such issues can become important physics-wise.

I would be very happy to know if there’s a work around to work with such scenarios, even if it’s not BDTG.

Many thanks.

Best regards,

Shankha.

---

<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 13, 2021, 9:13am UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/4 "2021-04-13T09:13:33Z")

</div>

Hi,  
Looking at you macro, I see that the cause of the error you are getting is due to negative variances.  
These are used to some of the input transformations, like decorrelations.  
Just use minimal transformations, for example using `Transformations=I,G,P` seems to work for me on your input data

Lorenzo

---

<div class="post-metadata">

**Author:** ![shankha\_banerjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shankha_banerjee/32/25531_2.png) [@shankha\_banerjee](https://root-forum.cern.ch/u/shankha_banerjee)\
**Post date:** [April 13, 2021, 10:48am UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/5 "2021-04-13T10:48:42Z")

</div>

Hi,

Thanks a lot. Indeed changing to Transformations=I,G,P is working without any run-time errors. However, the results are not making any sense. I see that the input variables are shown as something that I don’t expect and this is the same for the BDT variable.

I am still working with the “Pray” option.

I would really appreciate if you can look into the graphs once.

Many thanks.

Best regards,

Shankha.[input.pdf](https://root-forum.cern.ch/uploads/short-url/bwymdWhmSIl6rWUD6ZAuYPJUpYN.pdf) (20.0 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:** [April 13, 2021, 12:07pm UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/6 "2021-04-13T12:07:30Z")

</div>

Hi,

I need all your input files (also for the backgrounds) in order to run properly your code

Lorenzo

---

<div class="post-metadata">

**Author:** ![shankha\_banerjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shankha_banerjee/32/25531_2.png) [@shankha\_banerjee](https://root-forum.cern.ch/u/shankha_banerjee)\
**Post date:** [April 13, 2021, 12:55pm UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/7 "2021-04-13T12:55:10Z")

</div>

Hi,

I am attaching the files as a Dropbox link due to the size constraint.

> **[root\_files](https://www.dropbox.com/sh/zk4pxxetddt40e2/AABf_fxFRYA9qfe2kNQF8xKea?dl=0)**
>
> Shared with Dropbox

Please let me know if you are unable to access the files.

Many thanks.

Cheers,

Shankha.

---

<div class="post-metadata">

**Author:** ![shankha\_banerjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shankha_banerjee/32/25531_2.png) [@shankha\_banerjee](https://root-forum.cern.ch/u/shankha_banerjee)\
**Post date:** [April 19, 2021, 9:58am UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/9 "2021-04-19T09:58:31Z")

</div>

Hi Lorenzo,

Apologies for bothering again. Have you had a chance to look at the code with all the .root files?

Many thanks.

Cheers,

Shankha.

---

<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 19, 2021, 2:45pm UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/10 "2021-04-19T14:45:53Z")

</div>

Hi Shankha,

Sorry for my delay, I had not yet looked at your data, but I willl try to do as soon as possible,

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![shankha\_banerjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shankha_banerjee/32/25531_2.png) [@shankha\_banerjee](https://root-forum.cern.ch/u/shankha_banerjee)\
**Post date:** [April 21, 2021, 12:51pm UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/11 "2021-04-21T12:51:45Z")

</div>

Hi Lorenzo,

Thanks a lot. I will await your message.

Cheers,

Shankha.

---

<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 22, 2021, 3:58pm UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/12 "2021-04-22T15:58:06Z")

</div>

Hi,  
Sorry for my late reply. I could run your code on your file. The results seem ok to me, but it is difficult to judge since I don’t know your problem.  
In any case , here is the output ROOT file I get,  
[TMVA.root](https://root-forum.cern.ch/uploads/short-url/qyZPnPqkbE7dQ1ge7nYzO0Lf8FO.root) (2.2 MB)

---

<div class="post-metadata">

**Author:** ![shankha\_banerjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shankha_banerjee/32/25531_2.png) [@shankha\_banerjee](https://root-forum.cern.ch/u/shankha_banerjee)\
**Post date:** [April 23, 2021, 7:46pm UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/13 "2021-04-23T19:46:53Z")

</div>

Hi Lorenzo,

Thanks a lot for replying and for checking the code. I just have a few questions and clarifications to make.

Did you finally take the following transformation (code is also attached)?

```
TMVA::Factory *factory = new TMVA::Factory( "TMVAClassification", outputFile,
		"!V:!Silent:Color:DrawProgressBar:Transformations=I,G,P" );

```

With the following transformation, I am having a hard time understanding the input variables, the BDTG score and the significance graph. Are you also getting similar plots? I am unable to make any sense of these plots. The conventional way that I am used to seeing the BDT score is quite different from what is reflected in this graph.

Apologies for bothering again but I would really appreciate if you help me understand these graphs or if you used some other tweaks in your code. May be I am missing something.

Many thanks once again for your time.

Best regards,

Shankha.[BDTG.pdf](https://root-forum.cern.ch/uploads/short-url/gxLEzkduyNUytoOAgobaQz22IQN.pdf) (15.2 KB) [input.pdf](https://root-forum.cern.ch/uploads/short-url/cZ2sr9gay2mWOXmbc7LXntdVgZQ.pdf) (20.0 KB) [significance.pdf](https://root-forum.cern.ch/uploads/short-url/5ODfCqb7MzNGES4sjl8Ud8vq2m3.pdf) (157.2 KB)[TMVAClassification\_ggH.C](https://root-forum.cern.ch/uploads/short-url/gTe8d8SM9Ke0WkJQci34e8IEzPP.C) (6.9 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:** [April 26, 2021, 6:47am UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/14 "2021-04-26T06:47:25Z")

</div>

Hi,  
I have been using only “I” as transformations. The others , due to the negative weights, might have problems.  
You might need some dedicated transformations for your case, that correctly take into accounts negative weights.

Lorenzo

---

<div class="post-metadata">

**Author:** ![shankha\_banerjee](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shankha_banerjee/32/25531_2.png) [@shankha\_banerjee](https://root-forum.cern.ch/u/shankha_banerjee)\
**Post date:** [May 13, 2021, 10:44am UTC](https://root-forum.cern.ch/t/handling-negative-weight-events-with-bdtg/44373/15 "2021-05-13T10:44:38Z")

</div>

Thanks a lot Lorenzo for your help.

Shankha.
