# TMVAGUI ROC curve range

**URL:** <https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500>\
**Category:** TMVA\
**Tags:** python\
**Created:** [March 29, 2018, 9:42am UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500 "2018-03-29T09:42:01Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mesmeriza](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/838e76/32.png) [@mesmeriza](https://root-forum.cern.ch/u/mesmeriza)\
**Post date:** [March 29, 2018, 9:42am UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/1 "2018-03-29T09:42:01Z")

</div>

Hi guys!

I am new to TMVA and I played around a bit with the TMVA GUI and I noticed that the y-axis (background rejection) is not plotted from 0 to 1, but from 0.2 to 1 … How can I change this range? Is it just a matter of plotting or is it only calculated in the range of [0.2, 1]?

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 29, 2018, 2:08pm UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/2 "2018-03-29T14:08:25Z")

</div>

Hi,

It is just a matter of plotting it. But to change it you would need to modify this file :

> <https://github.com/root-project/root/blob/master/tmva/tmvagui/src/efficiencies.cxx#L22>

and change line 22 from 0.8 to 1.0  
and rebuild ROOT

Lorenzo

---

<div class="post-metadata">

**Author:** ![mesmeriza](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/838e76/32.png) [@mesmeriza](https://root-forum.cern.ch/u/mesmeriza)\
**Post date:** [March 29, 2018, 2:15pm UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/3 "2018-03-29T14:15:05Z")

</div>

Thanks for the quick answer!  
What other way is there to get a ROC curve, without using the TMVAGUI?  
I found this function: TGraph \* GetROCCurve (const UInt\_t points=100) in the TMVA::ROCCurve class.  
Does it the same as the TMVAGUI?  
Also, since I am using TMVA via python, I am not sure how to use the function porperly and haven’t found an example online.

Thanks a lot!

---

<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 29, 2018, 2:24pm UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/4 "2018-03-29T14:24:43Z")

</div>

HI,

Yes , you should be able to use this function, also from Python. In case of problems, please let me know

Lorenzo

---

<div class="post-metadata">

**Author:** ![mesmeriza](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/838e76/32.png) [@mesmeriza](https://root-forum.cern.ch/u/mesmeriza)\
**Post date:** [March 30, 2018, 10:16am UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/5 "2018-03-30T10:16:13Z")

</div>

Hi Lorenzo,

Thanks again. I tried it and I get an ''TypeError: none of the 4 overloaded methods succeeded." error. What am I doing wrong?  
I added the relevant code below.

* * *

```
...

output = TFile('tmva_output.root', 'recreate')

factory = TMVA.Factory('classifier', output,
                   ":".join([
                            "!V",
                            "!Silent",
                            "Color",
                            "DrawProgressBar",
                            "AnalysisType=Classification"]
                            ))
         

data = TMVA.DataLoader(".")

    
for n in range(n_vars): # adding the variables
    name = predictors[n] # the array preditors contains the column names of my variables
    data.AddVariable(name, 'F')
   
# Call root_numpy's utility functions to add events from the arrays
add_classification_events(data, X_train, y_train) 

add_classification_events(data, X_test, y_test, test=True)  

data.PrepareTrainingAndTestTree(TCut('1'), 'NormMode=EqualNumEvents')

BookMethod = factory.BookMethod

# add methods that you want to test on the data
BookMethod(data, 'Cuts', 'testCuts') # simple rectangular cuts

factory.TrainAllMethods()
factory.TestAllMethods()
factory.EvaluateAllMethods()

roc = factory.GetROCCurve(data) # this doesn't work

```

* * *

Cheers and happy easter!

---

<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 30, 2018, 12:08pm UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/6 "2018-03-30T12:08:11Z")

</div>

Hi

This looks [to.me](http://to.me) to be a PyRoot problem in getting the right overload.

Maybe @etejedor can help you with this

Lorenzo

-------- Messaggio originale --------

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [April 3, 2018, 10:02am UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/7 "2018-04-03T10:02:01Z")

</div>

Hi @mesmeriza,

What overload of `GetROCCurve` do you want to use?

[https://root.cern.ch/doc/v612/classTMVA\_1\_1Factory.html](https://root.cern.ch/doc/v612/classTMVA_1_1Factory.html)

I tried the one with this signature, which seems to be the one that you are trying to use in your code:

`TCanvas * GetROCCurve (DataLoader *loader, UInt_t iClass=0)`

and it does find the overload from PyROOT.

What version of ROOT are you using? Could you share a reproducer of your issue or alternatively try with the method with signature:

`TCanvas * GetROCCurve (TString datasetname, UInt_t iClass=0)`

Cheers,

Enric

---

<div class="post-metadata">

**Author:** ![mesmeriza](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/838e76/32.png) [@mesmeriza](https://root-forum.cern.ch/u/mesmeriza)\
**Post date:** [April 3, 2018, 10:37am UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/8 "2018-04-03T10:37:19Z")

</div>

Hi Enric,

Thanks a lot for your reply! I dont have a preference of which overload to use.

Maybe there is something wrong with my dataloader? is this correct: data = TMVA.DataLoader(".") ?

My ROOT version is: 6.08/02

I wanted to try TCanvas \* GetROCCurve (TString datasetname, UInt\_t iClass=0), but I don’t know what is meant by datasetname - I tried “.” but that doesn’t work.

(Apologies if these are stupid questions/mistakes)

Cheers!

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [April 3, 2018, 11:13am UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/9 "2018-04-03T11:13:52Z")

</div>

Hi @mesmeriza,

Can you paste the error message that you get for each overload that you try?

Regarding the meaning of the parameters, I will let @moneta comment on it.

Cheers,  
Enric

---

<div class="post-metadata">

**Author:** ![mesmeriza](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/838e76/32.png) [@mesmeriza](https://root-forum.cern.ch/u/mesmeriza)\
**Post date:** [April 3, 2018, 11:36am UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/10 "2018-04-03T11:36:47Z")

</div>

Hi Enric,

Sure, I attached a text file with the complete console output of the error. The most important part at the end:

Traceback (most recent call last):  
File “tmva\_opt\_test.py”, line 243, in   
roc = factory.GetROCCurve(data)  
TypeError: none of the 4 overloaded methods succeeded. Full details:  
TGraph\* TMVA:🏭:GetROCCurve(TMVA::DataLoader\* loader, TString theMethodName, bool fLegend = kTRUE) =\>  
takes at least 2 arguments (1 given)  
TGraph\* TMVA:🏭:GetROCCurve(TString datasetname, TString theMethodName, bool fLegend = kTRUE) =\>  
takes at least 2 arguments (1 given)  
TCanvas\* TMVA:🏭:GetROCCurve(TMVA::DataLoader\* loader) =\>  
problem in C++; program state has been reset  
TCanvas\* TMVA:🏭:GetROCCurve(TString datasetname) =\>  
could not convert argument 1

Cheers

[error\_msg\_TMVA.txt](https://root-forum.cern.ch/uploads/default/original/3X/b/9/b9becedd3898c800c587883f2a67cdee7e291306.txt) (9.5 KB)

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [April 3, 2018, 12:15pm UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/11 "2018-04-03T12:15:17Z")

</div>

Hi @mesmeriza,

Thank you, can you also share a minimal reproducer along with its input data (if any).

Another thing you could try in the meantime is to upgrade to ROOT 6.12, like I mentioned in a previous post I do not have problems with these overloads in 6.12.

Cheers,  
Enric

---

<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 4, 2018, 12:53pm UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/12 "2018-04-04T12:53:01Z")

</div>

Hi,

The dataset name is the name of the DataLoader class.  
I would however , as suggested by Eric, use the latest ROOT version.

Lorenzo

---

<div class="post-metadata">

**Author:** ![NgJunKai](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ngjunkai/32/30046_2.png) [@NgJunKai](https://root-forum.cern.ch/u/NgJunKai)\
**Post date:** [July 24, 2022, 3:28am UTC](https://root-forum.cern.ch/t/tmvagui-roc-curve-range/28500/13 "2022-07-24T03:28:43Z")

</div>

I am using ROOT installed in the conda environment. How to rebuild in this kind of scenario ?
