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]?
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 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
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)
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
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.