Home | News | Documentation | Download

How to increase granularity of ROC?

Dear ROOT experts,

I’m doing TMVA by following the tutorial macro named TMVAClassification.C:

I saw that the ROC expressed with 99 points from 0 to 1 in the output of TMVA.
I want to increase the granularity of ROC instead of using default setting.
Could someone guide me how can I do this?

Thanks in advance,
Jongho

Hi,

Unfortunately I noticed that the function TMVA::Factory::GetROCCurve is missing a parameter specifying the number of points (the default is 100).
I will add this option. As a workaround the solution is to create the ROC curve from the TMVA output fil.
Here is an example on how to do from the outputfile of TMVAClassification.C for the BDT method.

TFile f("TMVA.root");
auto TestTree = (TTree*) f.Get("dataset/TestTree");
// retrieve from the Testing tree the mva output plus weight and class id
int n = TestTree->Draw("BDT:weight:classID","");
// fill vector for the 3 quantities
std::vector<float> mvas(TestTree->GetV1(), TestTree->GetV1()+n);                                                                                                                       
std::vector<float> weights(TestTree->GetV2(), TestTree->GetV2()+n);    
std::vector<bool> targets(TestTree->GetV3(), TestTree->GetV3()+n); 
// classID ==0 is signal , instead for ROC target==1 is considered signal
// need to flip boolean vector
targets.flip();
TMVA::ROCCurve roc( mvas, targets,weights);
// get a graph given number of points (e.g. 1000)
auto curve = roc.GetROCCurve(1000);
curve->Draw();

Lorenzo

1 Like

Hi Lorenzo,
Thanks for your detailed answer with example!
I’ll try above example to draw ROC curve.

Hi @moneta,

When I tried this macro, everything was fine except the last line.
It opens a canvas, however, the ROC curve is not appear.
I’ve checked that three vectors were filled with proper values.
Can you please give some help?

I’m using ROOT v6.22.02 with ubuntu20 - gcc9.3 binary distribution.

Jongho

Try

curve->Draw("AP");

curve->Draw("AP") doesn’t work either.
I also tried manually by making a canvas and add c1->Update(); just after Draw command.
The output is below.

Jongho

Can you please post you code so I can reproduce this ?
Thank you

Thanks for taking care of this issue.
You can get input of the code from here
high_granularity_roc.cpp (1.3 KB)

Jongho

Hi @moneta

I just got the ROC curve by changing the following command line:
TMVA::ROCCurve roc(mvas, targets, weights);
to
TMVA::ROCCurve *roc = new TMVA::ROCCurve(mvas, targets, weights);

Jongho