How to get ROC curve for TMVA::Reader?

Hi all,

I have trained the BDT and now have the weights. Then, I apply this to a mixed of signal and background events (data)

Create TMVA::Reader and add BDT method from weight file
Read in data from tree

For event in tree
apply method
store the BDT response and the corresponding variables to the output
End for

and now I want find out the ROC curve as a check of its performance on the data events. My signal and background efficiency definition is basically eff = N(BDT)/N(S/B) as N(BDT) corresponds to the # of signal and background events passing BDT and N(S/B) all signal(S) and background(B) events. Basically, what is missing here is my S and B class in the tree. How can I store them?

Many thanks.

Hi,

Running the reader on all events for signal and background data you can get the vector of mva values for the two data sets. From those vectors you can create a ROCCurve class and get the graphics curve, see
https://root.cern.ch/doc/master/classTMVA_1_1ROCCurve.html

Lorenzo

Hi @moneta I have my weights in an xml file. Is there an easy way to read them into a vector of weights? I am not sure how to read them in using:

TMVA::ROCCurve::ROCCurve (values, targets, weights).

It doesn’t seem to work with just TMVA::ROCCurve::ROCCurve (values, targets)

Thanks!

Hi,
The XML file does not contain the event weights, but the parameter of your method (NN or BDT). The event weights are normally included in your input data file.
If your data are unweighted, you don’t need to provide the vector of weights, but if you use a vector all filled with ones, it will work too. In general for unweighted data, you should be able to use for the ROC curve, one of these 2 constructor:

 TMVA::ROCCurve::ROCCurve (values, targets)

Where values is a std::vector<float> with all th outputs of your ML method, and targets is a vector of bool (true for signal events and false for background events).

Or you can use

 TMVA::ROCCurve::ROCCurve (signal_values, background_values)

Where signal_values and background_values are std::vector<float> with the outputs of the signal and background events.

Best,

Lorenzo