# TMVA Plot Roc Curve From Test-Points

**URL:** <https://root-forum.cern.ch/t/tmva-plot-roc-curve-from-test-points/39273>\
**Category:** TMVA\
**Tags:** tmva\
**Created:** [May 5, 2020, 9:26pm UTC](https://root-forum.cern.ch/t/tmva-plot-roc-curve-from-test-points/39273 "2020-05-05T21:26:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Str55](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/str55/32/32911_2.png) [@Str55](https://root-forum.cern.ch/u/Str55)\
**Post date:** [May 5, 2020, 9:26pm UTC](https://root-forum.cern.ch/t/tmva-plot-roc-curve-from-test-points/39273/1 "2020-05-05T21:26:07Z")

</div>

Hi, I have a question about making a roc curve using TMVA. I have an array of the known weights of some events:

```auto
known_weights = [1, 1, -1, 1, -1 ...]

```

and what my BDTs in TMVA evaluated those events to:

```auto
tmva_eval = [0.8, 0.5, -0.3 ...]

```

Is there an easy way to plot a roc curve (similar to trainingRejBvsS from TMVA’s output file) from these arrays?

It looks like this [https://root.cern/doc/v614/ROCCurve\_8cxx\_source.html#l00056](https://root.cern/doc/v614/ROCCurve_8cxx_source.html#l00056)  
may be what I’m looking for, but it’s not clear which of my arrays would be _mvaValues_ and which would be _mvaWeights_, and I have no idea what _mvaTargets_ would be.

Thank you in advance.

---

<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:** [May 6, 2020, 8:13am UTC](https://root-forum.cern.ch/t/tmva-plot-roc-curve-from-test-points/39273/2 "2020-05-06T08:13:06Z")

</div>

Hi,  
The ROCCurve class can receive as input a vector for the MVA (e.g. BDT) evaluated values for both signal and background, _mvaValues_ and a boolean vector for targets, _mvaTargets_ ( false for background, true for signal events) and a weight vector _mvaWeights_.  
Otherwise you can also pass as input separate vectors for signal values, background values, signal weight values and background weight values.

Hope it is clear now, if not I can provide you an example

Best regards

Lorenzo

---

<div class="post-metadata">

**Author:** ![Str55](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/str55/32/32911_2.png) [@Str55](https://root-forum.cern.ch/u/Str55)\
**Post date:** [May 6, 2020, 1:41pm UTC](https://root-forum.cern.ch/t/tmva-plot-roc-curve-from-test-points/39273/3 "2020-05-06T13:41:37Z")

</div>

Hi Lorenzo, thank you for the quick reply!

So as I understand it, in my case, since +1 corresponds to signal and -1 to background I would convert the vector

```auto
known_weights = [1, 1, -1, 1, -1 ...]

```

to

```auto
mvaTargets = [True, True, False, True, False ...]

```

and leave `tmva_eval` as is, using that as _mvaValues_

What then would _mvaWeights_ be?

Thank you!

Cheers,  
Steve

---

<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:** [May 6, 2020, 1:52pm UTC](https://root-forum.cern.ch/t/tmva-plot-roc-curve-from-test-points/39273/4 "2020-05-06T13:52:26Z")

</div>

Hi,  
_mvaWeights_ are the single event weights, if you don’t have they are by default equal to 1. You can then use in that case the constructor without them,  
[https://root.cern/doc/v614/classTMVA\_1\_1ROCCurve.html#ac518969f5978bdb7b8b3a9950ff320e5](https://root.cern/doc/v614/classTMVA_1_1ROCCurve.html#ac518969f5978bdb7b8b3a9950ff320e5)

Lorenzo

---

<div class="post-metadata">

**Author:** ![Str55](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/str55/32/32911_2.png) [@Str55](https://root-forum.cern.ch/u/Str55)\
**Post date:** [May 6, 2020, 1:59pm UTC](https://root-forum.cern.ch/t/tmva-plot-roc-curve-from-test-points/39273/5 "2020-05-06T13:59:24Z")

</div>

Hi Lorenzo,

Thank you very much for the explanation!  
I was unaware that each event could have an associated weight.

-Steve
