# How to obtain BDT score at specific signal efficiency?

**URL:** <https://root-forum.cern.ch/t/how-to-obtain-bdt-score-at-specific-signal-efficiency/41536>\
**Category:** TMVA\
**Created:** [September 21, 2020, 11:59pm UTC](https://root-forum.cern.ch/t/how-to-obtain-bdt-score-at-specific-signal-efficiency/41536 "2020-09-21T23:59:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kawaho](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kawaho/32/23413_2.png) [@kawaho](https://root-forum.cern.ch/u/kawaho)\
**Post date:** [September 21, 2020, 11:59pm UTC](https://root-forum.cern.ch/t/how-to-obtain-bdt-score-at-specific-signal-efficiency/41536/1 "2020-09-21T23:59:12Z")

</div>

Hi friends,  
I am looking for way to output the BDT score that corresponds to a specific signal efficiency. Specifically, I want to know what BDT score corresponds to signal efficiency in steps of 1% changes, like what is the BDT score at 99% signal efficiency, 98% signal efficiency, 97% signal efficiency and so on. Is there a way to do it?  
Thanks a lot,  
Ka Wa

---

<div class="post-metadata">

**Author:** ![oshadura](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oshadura/32/14460_2.png) [@oshadura](https://root-forum.cern.ch/u/oshadura)\
**Post date:** [September 22, 2020, 7:31am UTC](https://root-forum.cern.ch/t/how-to-obtain-bdt-score-at-specific-signal-efficiency/41536/2 "2020-09-22T07:31:56Z")

</div>

@swunsch @moneta could you please help here?

Cheers,  
Oksana.

---

<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:** [September 22, 2020, 12:19pm UTC](https://root-forum.cern.ch/t/how-to-obtain-bdt-score-at-specific-signal-efficiency/41536/3 "2020-09-22T12:19:03Z")

</div>

Hi,

I think you just need to call `TMath::Quantiles` using as input probability p=1-signal\_efficiency  
on the BDT score vector data that you can obtain from the output ROOT file of the BDT.  
If you need I can provide you an example

Best

Lorenzo

---

<div class="post-metadata">

**Author:** ![kawaho](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kawaho/32/23413_2.png) [@kawaho](https://root-forum.cern.ch/u/kawaho)\
**Post date:** [September 22, 2020, 4:06pm UTC](https://root-forum.cern.ch/t/how-to-obtain-bdt-score-at-specific-signal-efficiency/41536/4 "2020-09-22T16:06:10Z")

</div>

Hi Lorenzo,  
Thanks for your reply! By the “BDT score vector data”, do you refer to the tree inside the root file? An example would be nice. Thank you so much.  
Cheers,  
Ka Wa

---

<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:** [September 23, 2020, 9:25am UTC](https://root-forum.cern.ch/t/how-to-obtain-bdt-score-at-specific-signal-efficiency/41536/5 "2020-09-23T09:25:34Z")

</div>

HI,

As example you can run the tutorial `TMVA/TMVA_Higgs_Classification.C` that performs a classification using BDT.  
[https://root.cern.ch/doc/master/TMVA\_\_Higgs\_\_Classification\_8C.html](https://root.cern.ch/doc/master/TMVA __Higgs__ Classification_8C.html)

The output file generated by the tutorial is called `Higgs_ClassificationOutput.root`  
Then you can run this code from the output file to get the BDT score from the Test Tree on the signal events

```auto
{
  TFile f("Higgs_ClassificationOutput.root");
  auto t = (TTree*) f.Get("dataset/TestTree");
  int n = t->Draw("BDT","classID==0");
  // retrieve the data used to fill the BDT score histogram plot
  auto scoreVector = t->GetV1(); 
  // probabilities used for computing the quantiles 
  double p[99];
  for (int i = 0; i < 99; ++i) p[i] = 0.01*double(i+1); 
  double q[99]; 
  TMath::Quantiles(n, 99, scoreVector, q, p, false); 
  for (int i = 0; i< 99; ++i) {
     std::cout << " signal efficiency " << 1.-p[i] << " BDT score " << q[i] << std::endl;  
 } 
}

```
