# Overtraining test obtained from TMVA

**URL:** <https://root-forum.cern.ch/t/overtraining-test-obtained-from-tmva/32148>\
**Category:** TMVA\
**Created:** [January 2, 2019, 4:55am UTC](https://root-forum.cern.ch/t/overtraining-test-obtained-from-tmva/32148 "2019-01-02T04:55:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JungChang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@JungChang](https://root-forum.cern.ch/u/JungChang)\
**Post date:** [January 2, 2019, 4:55am UTC](https://root-forum.cern.ch/t/overtraining-test-obtained-from-tmva/32148/1 "2019-01-02T04:55:59Z")

</div>

Dear Sir,

I have a question about the KS test for overtraining check.  
From this topic, it seems the KS test number should be close to 0.5 to avoid overtraining.

> [@About the BDT control plot and the decision boundary](https://root-forum.cern.ch/t/about-the-bdt-control-plot-and-the-decision-boundary/28942/3):
>
> Dear Kim, Oh I just saw them in the user guide and the TMVA GUI, then tried to interpret them to help us understand what’s happening in the training. But it seems not that easy… Thanks for the explanation. And BTW I have another question on the Kolmogorov-Smirnov test(to estimate the overfitting) and hope you can help me with the print out: Testing efficiency compared to training efficiency (overtraining check) — Perform Kolmogorov-Smirnov tests — Goodness of signal (background) consisten…

In my case the KS test for signal and background is always smaller than 0.2. See attached picture.  
I trained with BDT. May I ask how can I avoid the overtraining? Through the understanding of KS test? Thanks!

![Selection_070](https://root-forum.cern.ch/uploads/default/original/3X/0/8/08abac9130e59e603a5397189f0c784ec6c519af.png)

Best,  
Jung

---

<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:** [January 7, 2019, 8:12pm UTC](https://root-forum.cern.ch/t/overtraining-test-obtained-from-tmva/32148/2 "2019-01-07T20:12:13Z")

</div>

Hi Jung!

Indeed the KS-test should return 0.5 for identically distributed data. To my understanding however the KS-test is rather weak in that it requires a large sample size to be effective.

In my quick test of 2 slightly separated normal distributions for signal and background using a shallow BDT with 800 trees the KS-test started being informative around a sample size of 100000.

To reduce overtraining, use either more data or regularise your BDT with e.g. simpler trees (depth=1 or 2), large `MinNodeSize`, and large `nCuts`. (As I assume you understand already looking at your table.)

You can also look into bagged boosting (`UseBaggedBoost` and `BaggedSampleFraction`) and feature subsampling with `UseRandomisedTrees` and `UseNvars`.

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![JungChang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@JungChang](https://root-forum.cern.ch/u/JungChang)\
**Post date:** [January 8, 2019, 1:43am UTC](https://root-forum.cern.ch/t/overtraining-test-obtained-from-tmva/32148/3 "2019-01-08T01:43:50Z")

</div>

Dear Kim,

Thanks a lot for the reply! I got it.

Best,  
Jung
