# Unbalanced data TMVA

**URL:** <https://root-forum.cern.ch/t/unbalanced-data-tmva/36218>\
**Category:** TMVA\
**Created:** [October 3, 2019, 10:45pm UTC](https://root-forum.cern.ch/t/unbalanced-data-tmva/36218 "2019-10-03T22:45:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anprodri](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/8dc957/32.png) [@anprodri](https://root-forum.cern.ch/u/anprodri)\
**Post date:** [October 3, 2019, 10:45pm UTC](https://root-forum.cern.ch/t/unbalanced-data-tmva/36218/1 "2019-10-03T22:45:42Z")

</div>

Dear TMVA users,

Does TMVA have a system to manage unbalanced data for training ML models, like BDT or DNN for example? If it does, is it automatic or do I have to specify a command?

Thanks in advance.  
Regards.

---

<div class="post-metadata">

**Author:** ![kialbert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kialbert/32/16537_2.png) [@kialbert](https://root-forum.cern.ch/u/kialbert)\
**Post date:** [October 4, 2019, 2:46pm UTC](https://root-forum.cern.ch/t/unbalanced-data-tmva/36218/2 "2019-10-04T14:46:02Z")

</div>

Hi,

See the [TMVA Users’ guide p. 21-22](https://root.cern.ch/download/doc/tmva/TMVAUsersGuide.pdf). The setting you are looking for is called `NormMode` for the `Dataloader::PrepareTrainingAndTestTree`.

The default balances the weights of all classes to be equal (with an average weight per signal event of 1).

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![anprodri](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/8dc957/32.png) [@anprodri](https://root-forum.cern.ch/u/anprodri)\
**Post date:** [October 7, 2019, 3:46pm UTC](https://root-forum.cern.ch/t/unbalanced-data-tmva/36218/3 "2019-10-07T15:46:53Z")

</div>

Thanks for the answer.

Will I be able to do this if I’m using event-by-event weights with dataloader-\>SetBackgroundWeightExpression( “weight” )?

---

<div class="post-metadata">

**Author:** ![kialbert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kialbert/32/16537_2.png) [@kialbert](https://root-forum.cern.ch/u/kialbert)\
**Post date:** [October 9, 2019, 9:29am UTC](https://root-forum.cern.ch/t/unbalanced-data-tmva/36218/4 "2019-10-09T09:29:50Z")

</div>

Hi,

Yes!

The events are normalised event-by-event. In the default case I think the signal class is normalised to have an average event weight of 1, and the other classes are then normalised to have the same weighted sum as signal. This retains the relative weight ratio within classes.

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![anprodri](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/8dc957/32.png) [@anprodri](https://root-forum.cern.ch/u/anprodri)\
**Post date:** [October 10, 2019, 3:42pm UTC](https://root-forum.cern.ch/t/unbalanced-data-tmva/36218/5 "2019-10-10T15:42:03Z")

</div>

I understand now. Thank you very much for your help!
