TMVAGUI ROC curve range

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

Hi,

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

and change line 22 from 0.8 to 1.0
and rebuild ROOT

Lorenzo

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!

HI,

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

Lorenzo

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!

Hi

This looks to.me to be a PyRoot problem in getting the right overload.

Maybe @etejedor can help you with this

Lorenzo

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

Hi @mesmeriza,

What overload of GetROCCurve do you want to use?

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

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!

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

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::factory::GetROCCurve(TMVA::DataLoader* loader, TString theMethodName, bool fLegend = kTRUE) =>
takes at least 2 arguments (1 given)
TGraph* TMVA::factory::GetROCCurve(TString datasetname, TString theMethodName, bool fLegend = kTRUE) =>
takes at least 2 arguments (1 given)
TCanvas* TMVA::factory::GetROCCurve(TMVA::DataLoader* loader) =>
problem in C++; program state has been reset
TCanvas* TMVA::factory::GetROCCurve(TString datasetname) =>
could not convert argument 1

Cheers

error_msg_TMVA.txt (9.5 KB)

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

Hi,

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

Lorenzo

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