# BDT method with XGBoost and TMVA

**URL:** <https://root-forum.cern.ch/t/bdt-method-with-xgboost-and-tmva/54390>\
**Category:** TMVA\
**Created:** [April 6, 2023, 10:16am UTC](https://root-forum.cern.ch/t/bdt-method-with-xgboost-and-tmva/54390 "2023-04-06T10:16:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antara](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/antara/32/33019_2.png) [@Antara](https://root-forum.cern.ch/u/Antara)\
**Post date:** [April 6, 2023, 10:16am UTC](https://root-forum.cern.ch/t/bdt-method-with-xgboost-and-tmva/54390/1 "2023-04-06T10:16:07Z")

</div>

I am trying to use the XGBoost to perform BDT analysis of signal and background for a set of final states. My code file performs well in some sets of sample events. Whereas in some cases, I get stuck with the line that ‘The kernel appears to have died. It will restart automatically.’ This is happening although the dataset size is small (less than 20 MB). Whereas, if I use the same dataset in TMVA BDT analysis, I face no error. Is there some problem with my dataset, in particular? Could you help me in understanding, why this is happening despite the file size being small and running in TMVA without any error?

---

<div class="post-metadata">

**Author:** ![Antara](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/antara/32/33019_2.png) [@Antara](https://root-forum.cern.ch/u/Antara)\
**Post date:** [April 6, 2023, 10:37am UTC](https://root-forum.cern.ch/t/bdt-method-with-xgboost-and-tmva/54390/2 "2023-04-06T10:37:46Z")

</div>

I attach herewith the datafiles used. Signal files are :  
cutflow\_signunuh.root (total signal sample)  
sigTrainData.root (signal training sample)  
sigTestData.root (signal testing sample)  
[cutflow\_signunuh.root](https://root-forum.cern.ch/uploads/short-url/sP7YIenBbAeEBXoD2iqeuQTdQ3w.root) (830.1 KB)  
[sigTestData.root](https://root-forum.cern.ch/uploads/short-url/whhP6MvkvRB5i8Jl6NNFVOcwHLW.root) (417.0 KB)  
[sigTrainData.root](https://root-forum.cern.ch/uploads/short-url/awPr68vtrkQB6fd9wgFCHWTEUIo.root) (420.5 KB)

---

<div class="post-metadata">

**Author:** ![Antara](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/antara/32/33019_2.png) [@Antara](https://root-forum.cern.ch/u/Antara)\
**Post date:** [April 6, 2023, 10:41am UTC](https://root-forum.cern.ch/t/bdt-method-with-xgboost-and-tmva/54390/3 "2023-04-06T10:41:24Z")

</div>

Background samples are :  
[cutflow\_bkgnunuh.root](https://root-forum.cern.ch/uploads/short-url/9R4A9CGYdWZ58MYo7nUA6KRZtRd.root) (788.6 KB)  
[bkgTestData.root](https://root-forum.cern.ch/uploads/short-url/eVJJW2RNQ0fvAr5wHbYUTuxWdfa.root) (397.1 KB)  
[bkgTrainData.root](https://root-forum.cern.ch/uploads/short-url/3uQD1lhuEoKTz6Kyn5oomLYAls9.root) (399.5 KB)

cutflow\_bkgnunuh.root (total background sample)  
bkgTrainData.root (background training sample)  
bkgTestData.root (background testing sample)

Any help would be highly appreciated.

Thanks and regards,  
Antara

---

<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 6, 2023, 1:42pm UTC](https://root-forum.cern.ch/t/bdt-method-with-xgboost-and-tmva/54390/4 "2023-04-06T13:42:01Z")

</div>

Hi,  
This is maybe more a problem in XGBoost, but I could have a look at it. I would need also your code that you use for training the model and shows the error you have reported

Lorenzo

---

<div class="post-metadata">

**Author:** ![Antara](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/antara/32/33019_2.png) [@Antara](https://root-forum.cern.ch/u/Antara)\
**Post date:** [April 6, 2023, 2:44pm UTC](https://root-forum.cern.ch/t/bdt-method-with-xgboost-and-tmva/54390/5 "2023-04-06T14:44:03Z")

</div>

Thanks for the reply.

I attach herewith the codes I am using. I am using XGBoost v1.2 . Please have a look and kindly help me to be make it to working for the analysis.  
[tmva\_ee2vvh\_train\_sigbkg.cpp](https://root-forum.cern.ch/uploads/short-url/lDmlD3S66pCJTrO68GlbJ3BEwV.cpp) (11.5 KB)  
[Untitled33.ipynb](https://root-forum.cern.ch/uploads/short-url/yHtjnLTIndk6uqmzNsJmPkdDp2x.ipynb) (6.0 KB)

Thanks and regards,  
Antara

---

<div class="post-metadata">

**Author:** ![Antara](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/antara/32/33019_2.png) [@Antara](https://root-forum.cern.ch/u/Antara)\
**Post date:** [April 7, 2023, 7:26pm UTC](https://root-forum.cern.ch/t/bdt-method-with-xgboost-and-tmva/54390/6 "2023-04-07T19:26:10Z")

</div>

Hi,

It was to ask if you checked the code and came across similar error or not. I am confused of whether it is happening due to the dataset or due to any conflicting dependencies for xgboost. This code is running fine with some other datasets but not for several other datasets. I tried uninstalling existing required packages for the BDT analysis and downgrading the versions, still the same error ‘The kernel appears to have died.’ is coming. Please tell what to do in this regard?

Thanks  
Antara

---

<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 11, 2023, 8:25am UTC](https://root-forum.cern.ch/t/bdt-method-with-xgboost-and-tmva/54390/7 "2023-04-11T08:25:57Z")

</div>

Hi,

I think your notebook using XGBoost is having some issues and gives some error in XGBoost causing the Kernel to die. I have found one error, th enables `y` you pass ar not the 7th column of your data , but the 14th, Bit after fixing this I have still an error when calling `model.predict_proba(X_test)`. I am not expert in XGBoost and I don’t know what the problem is.  
I would suggest you using TMVA, any special reason you need to use XGBoost instead of TMVA ?

Lorenzo
