# ROC AUC discrepancy

**URL:** <https://root-forum.cern.ch/t/roc-auc-discrepancy/49098>\
**Category:** TMVA\
**Created:** [March 9, 2022, 10:11am UTC](https://root-forum.cern.ch/t/roc-auc-discrepancy/49098 "2022-03-09T10:11:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![11133](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/11133/32/25084_2.png) [@11133](https://root-forum.cern.ch/u/11133)\
**Post date:** [March 9, 2022, 10:11am UTC](https://root-forum.cern.ch/t/roc-auc-discrepancy/49098/1 "2022-03-09T10:11:11Z")

</div>

Hi forum!

I have a dilemma, so any help would be appreciated! When I train the DNN with TMVA (PyKeras method), I see the ROC-integ value on the terminal once the training ends. And recently, I also learned how to extract the ROC-Curve histogram from the root-file which TMVA creates after training. And for comparison, I take the integral from this ROC-curve histogram, and the results are not the same with the one which I see on the terminal.

Which result should I take as a truth? Any suggestions?

Cheers,

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [March 9, 2022, 10:13am UTC](https://root-forum.cern.ch/t/roc-auc-discrepancy/49098/2 "2022-03-09T10:13:41Z")

</div>

I think @moneta can help

---

<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:** [March 9, 2022, 2:14pm UTC](https://root-forum.cern.ch/t/roc-auc-discrepancy/49098/3 "2022-03-09T14:14:46Z")

</div>

Hi,

How are you getting the ROC integral afterwards ?  
What is printed after training when using Factory::EvaluateAllMethod is obtained from the full output data results. You can verify it using the function [`TMVA::Factory::GetRocIntegral`](https://root.cern.ch/doc/master/classTMVA_1_1Factory.html#a6f66be8082e37f8a6924a720c35335c5) or to see the curve calling `GetROCCurve`.

When you extract from the ROOT file, you should be careful to what you use, training or testing data and if you compute from an histogram there could be some interpolation effects that can cause some differences.  
If you have very big differences on the same data, then something else might be wrong, in that case please let us know and provide something to reproduce it

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![11133](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/11133/32/25084_2.png) [@11133](https://root-forum.cern.ch/u/11133)\
**Post date:** [March 9, 2022, 3:57pm UTC](https://root-forum.cern.ch/t/roc-auc-discrepancy/49098/4 "2022-03-09T15:57:59Z")

</div>

Hi,

Can you please provide a snapshot of the example how to use these functions?! I tried to invoke them, but have not succeeded. To be specific, I invoked GetRocCurve() function before EvaluateAllMethods() method, and GetRocIntegral after.

Regarding the question how I obtain the ROC AUC from the histogram TMVA saves, please find my code in the attachment.

Cheers,  
[TMVAplot\_RocCurve.C](https://root-forum.cern.ch/uploads/short-url/aLBiuKtklUhrWFJDyqzI28oSE8b.C) (1.6 KB)

---

<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:** [March 9, 2022, 10:15pm UTC](https://root-forum.cern.ch/t/roc-auc-discrepancy/49098/5 "2022-03-09T22:15:09Z")

</div>

Hi,

See at the end of some TMVA tutorials, such as this one, where the ROC curve are displayed:  
[https://root.cern.ch/doc/master/TMVA\_\_Higgs\_\_Classification\_8C.html](https://root.cern.ch/doc/master/TMVA __Higgs__ Classification_8C.html)

I see in your code that you compute from some the histograms and this can cause some differences compare to the other case where there are computed using the full data points.

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![11133](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/11133/32/25084_2.png) [@11133](https://root-forum.cern.ch/u/11133)\
**Post date:** [March 10, 2022, 11:12am UTC](https://root-forum.cern.ch/t/roc-auc-discrepancy/49098/6 "2022-03-10T11:12:49Z")

</div>

Hi,

Thank you for clairification! I can get now the ROC-Curve plot, however, the method GetRocIntegral does not still work. The error message is as follows:

AttributeError: ‘Factory’ object has no attribute ‘GetRocIntegral’

I’m running my project on lxplus and I use certain shell script to set the environmental variables. My guess is maybe I should use some other shell to set the latest version of TMVA ???

I just would like to confirm the true value of ROC AUC.

Cheers,

---

<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:** [March 10, 2022, 4:31pm UTC](https://root-forum.cern.ch/t/roc-auc-discrepancy/49098/7 "2022-03-10T16:31:48Z")

</div>

Hi,  
This is strange, which TMVA version are you using ?  
Normally you would need to add a line like this (this works for the TMVA\_Higgs\_Classification.C tutorial):

```auto
double auc = factory.GetROCIntegral(loader, "BDT");

```

Lorenzo

---

<div class="post-metadata">

**Author:** ![11133](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/11133/32/25084_2.png) [@11133](https://root-forum.cern.ch/u/11133)\
**Post date:** [March 10, 2022, 4:45pm UTC](https://root-forum.cern.ch/t/roc-auc-discrepancy/49098/8 "2022-03-10T16:45:59Z")

</div>

Hi,

Thank you very much!  
I’ve found very trivial mistake in my code! It worked!

Cheers,
