# TMVAMulticlass Specifying training / testing split

**URL:** <https://root-forum.cern.ch/t/tmvamulticlass-specifying-training-testing-split/51954>\
**Category:** TMVA\
**Created:** [October 13, 2022, 7:49pm UTC](https://root-forum.cern.ch/t/tmvamulticlass-specifying-training-testing-split/51954 "2022-10-13T19:49:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![smitmatt](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/smitmatt/32/26905_2.png) [@smitmatt](https://root-forum.cern.ch/u/smitmatt)\
**Post date:** [October 13, 2022, 7:49pm UTC](https://root-forum.cern.ch/t/tmvamulticlass-specifying-training-testing-split/51954/1 "2022-10-13T19:49:57Z")

</div>

Hello,

I would like to change the percentage of data used in training multiclass BDT’s, but cannot find documentation of the correct string to use. I see usually the following is used:

PrepareTrainingAndTestTree( MyCut, “NormMode=NumEvents:!V” );

Which defaults to a 50/50 split. I would like to, for example, use 95% of my data to train, and 5% to test.

For further clarification, Lets say I had 10000 Signal and Bkg events. In typical binary class decision trees, I could specify:

PrepareTrainingAndTestTree( MyCut, “nTrain\_Signal=9500:nTrain\_Background=9500:…”).

However, for multiclass BDT, I get the error:  
“ : The following options were specified, but could not be interpreted: ‘nTrain\_Background=9500:nTest\_Background==500’, please check!”

And my next best guess, “nTrain”, was not accepted.

Thanks!

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [October 14, 2022, 12:00pm UTC](https://root-forum.cern.ch/t/tmvamulticlass-specifying-training-testing-split/51954/2 "2022-10-14T12:00:36Z")

</div>

Did you try the [overload that takes the number of entries as arguments](https://root.cern/doc/master/classTMVA_1_1DataLoader.html#a07503b58cbd50ddf5687afb69f6cf1e7)? `DataLoader::PrepareTrainingAndTestTree ( const TCut & cut, Int_t NsigTrain, Int_t NbkgTrain, Int_t NsigTest, Int_t NbkgTest, const TString & otherOpt = "SplitMode=Random:!V" ) `

Did you try with `nTrain_Background=9500:nTest_Background=500` instead of `nTrain_Background=9500:nTest_Background==500` (i.e. `=`, not `==`)?

---

<div class="post-metadata">

**Author:** ![smitmatt](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/smitmatt/32/26905_2.png) [@smitmatt](https://root-forum.cern.ch/u/smitmatt)\
**Post date:** [October 14, 2022, 12:47pm UTC](https://root-forum.cern.ch/t/tmvamulticlass-specifying-training-testing-split/51954/3 "2022-10-14T12:47:20Z")

</div>

Hello, thank you for the reply.

I have tried these. I get the following error when trying the first suggestion:

: The following options were specified, but could not be interpreted: ‘nTrain\_Background=862117:nTest\_Background=45375’, please check!

As a reminder, I would like to train a 3 output class BDT, with 1 signal class and two background classes Bkg0 and Bkg1. I see an immediate problem with the first suggested option, as it only specifies a " NbkgTrain", and no “Nbkg1Train”.

I have also tried this overload: `PrepareTrainingAndTestTree(const TCut & cut, Int_t Ntrain, Int_t Ntest = -1)` to no avail.

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [October 17, 2022, 9:05am UTC](https://root-forum.cern.ch/t/tmvamulticlass-specifying-training-testing-split/51954/4 "2022-10-17T09:05:01Z")

</div>

@moneta could you have a look, please?

---

<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:** [October 17, 2022, 9:39am UTC](https://root-forum.cern.ch/t/tmvamulticlass-specifying-training-testing-split/51954/5 "2022-10-17T09:39:49Z")

</div>

Hi,  
Can you try using the name of the classes you have defined previously, since you have multiple backgrounds. For example:

```auto
dataloader->AddTree (signalTree,"Signal");
dataloader->AddTree (background0,"bg1");
dataloader->AddTree (background1,"bg2");
dataLoader->PrepareTrainingAndTestTree(myCut, "nTrain_Signal=1000:nTrain_bg1=1000:nTrain_bg2=1000:.....");

```

Best,

Lorenzo

---

<div class="post-metadata">

**Author:** ![smitmatt](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/smitmatt/32/26905_2.png) [@smitmatt](https://root-forum.cern.ch/u/smitmatt)\
**Post date:** [October 17, 2022, 8:23pm UTC](https://root-forum.cern.ch/t/tmvamulticlass-specifying-training-testing-split/51954/6 "2022-10-17T20:23:12Z")

</div>

Hello,

This seems to work! thank you. Is there documentation of this that I missed?

Cheers,

Matt

---

<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:** [October 17, 2022, 9:28pm UTC](https://root-forum.cern.ch/t/tmvamulticlass-specifying-training-testing-split/51954/7 "2022-10-17T21:28:38Z")

</div>

Hello,

Unfortunately not, it is not mention in the table 22 of the [TMVA Users Guide](https://root.cern.ch/download/doc/tmva/TMVAUsersGuide.pdf). We should add a note for the multi class case. Thank you for raising this issue,

Cheers

Lorenzo
