# TMVA cross validation over training check and K-S test

**URL:** <https://root-forum.cern.ch/t/tmva-cross-validation-over-training-check-and-k-s-test/52087>\
**Category:** TMVA\
**Created:** [October 25, 2022, 8:34pm UTC](https://root-forum.cern.ch/t/tmva-cross-validation-over-training-check-and-k-s-test/52087 "2022-10-25T20:34:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yao\_Yao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/yao_yao/32/23839_2.png) [@Yao\_Yao](https://root-forum.cern.ch/u/Yao_Yao)\
**Post date:** [October 25, 2022, 8:34pm UTC](https://root-forum.cern.ch/t/tmva-cross-validation-over-training-check-and-k-s-test/52087/1 "2022-10-25T20:34:40Z")

</div>

Dear experts,

I am using a 10-fold cross validation to train and test a signal vs background analysis, and I am looking into the over-training plot in the TMVAGui, that has the training and testing events plotted on the same plot. The plot is attached.

I don’t think the plot that the TMVAGui provides demonstrates the over-training situation, because the BDT score distribution of testing and training are exactly the same. It seems to me that because it is a 10-fold cross validation, all events are counted as both trained and tested. The K-S test value on the plot is 1 for both signal and background, which implies that it is plotting the same dataset for training and testing.

Is there another way to evaluate the over-training for cross-validation in TMVA package?

Thank you,  
Yao

 ![Screen Shot 2022-10-25 at 4.33.40 PM](https://root-forum.cern.ch/uploads/default/original/3X/b/f/bf058ed10d4267ae95b60883447c5e2b068eada7.png)

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [November 1, 2022, 4:36pm UTC](https://root-forum.cern.ch/t/tmva-cross-validation-over-training-check-and-k-s-test/52087/2 "2022-11-01T16:36:22Z")

</div>

Hi @Yao_Yao ,

sorry for the high latency. Let’s ask TMVA expert @moneta .

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![Yao\_Yao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/yao_yao/32/23839_2.png) [@Yao\_Yao](https://root-forum.cern.ch/u/Yao_Yao)\
**Post date:** [November 1, 2022, 5:11pm UTC](https://root-forum.cern.ch/t/tmva-cross-validation-over-training-check-and-k-s-test/52087/3 "2022-11-01T17:11:58Z")

</div>

Hi,

I think I find a solution here. So far I split the dataset into half training and half test in the dataloader, and the CV is only trained, tested and evaluated on the training part of the dataset. I use the other half to plot the test result. I am currently plotting it with my own plotting script. Please let me know if you have any comments.

Thank you,  
Yao

> [@Overtraining check with CrossValidation](https://root-forum.cern.ch/t/overtraining-check-with-crossvalidation/35360):
>
> Dear MVA experts, Now I’m tring to use CrossValidation for some classification work. However, from the output file of the tutorial code here: [https://root.cern/doc/master/TMVACrossValidation\_8C.html](https://root.cern/doc/master/TMVACrossValidation_8C.html), I found that the information in the output TrainTree and TestTree are completely the same. When I’m looking at the overtraining check plot from TMVAGui, the training part and testing part just overlap with each other. I’m wondering how to deal with the issue if I want to CrossValidation class. Ma…
