# Getting the sensitivty and specificity array

**URL:** <https://root-forum.cern.ch/t/getting-the-sensitivty-and-specificity-array/30105>\
**Category:** TMVA\
**Created:** [August 3, 2018, 6:23am UTC](https://root-forum.cern.ch/t/getting-the-sensitivty-and-specificity-array/30105 "2018-08-03T06:23:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![divyakuttan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@divyakuttan](https://root-forum.cern.ch/u/divyakuttan)\
**Post date:** [August 3, 2018, 6:23am UTC](https://root-forum.cern.ch/t/getting-the-sensitivty-and-specificity-array/30105/1 "2018-08-03T06:23:02Z")

</div>

Dear Experts,

Sorry for my ignorance. I want to plot the ROC curve manually for which I need the values of sensitivity and specificity array. Will you please help me to get them ?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [August 3, 2018, 6:42am UTC](https://root-forum.cern.ch/t/getting-the-sensitivty-and-specificity-array/30105/2 "2018-08-03T06:42:09Z")

</div>

It does not seems to be a ROOT specific question.

---

<div class="post-metadata">

**Author:** ![divyakuttan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@divyakuttan](https://root-forum.cern.ch/u/divyakuttan)\
**Post date:** [August 3, 2018, 6:49am UTC](https://root-forum.cern.ch/t/getting-the-sensitivty-and-specificity-array/30105/3 "2018-08-03T06:49:55Z")

</div>

Hi,

I am sorry. I am not very sure. I have installed ROOT 6.12.04 and tried running the example TMVAClassification.C . The GUI generated the ROC curve. I went inside the ROCCurve.cxx file and tried to change it. But didn’t help. That is why asked here.

---

<div class="post-metadata">

**Author:** ![kialbert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kialbert/32/16537_2.png) [@kialbert](https://root-forum.cern.ch/u/kialbert)\
**Post date:** [August 3, 2018, 10:58am UTC](https://root-forum.cern.ch/t/getting-the-sensitivty-and-specificity-array/30105/4 "2018-08-03T10:58:19Z")

</div>

Hi,

We currently don’t have an easy way of getting those two. What you can do for analysis type classification is

```auto
TMVA::MethodBase *method = dynamic_cast<TMVA::MethodBase *>(this->GetMethod(datasetname, theMethodName));
TMVA::DataSet *dataset = method->Data();
TMVA::Results *results = dataset->GetResults(theMethodName, Types::kTesting, Types::kClassification);

TMVA::ROCCurve *rocCurve = nullptr;
std::vector<Float_t> *mvaRes = dynamic_cast<ResultsClassification *>(results)->GetValueVector();
std::vector<Bool_t> *mvaResTypes = dynamic_cast<ResultsClassification *>(results)->GetValueVectorTypes();
std::vector<Float_t> mvaResWeights;

auto eventCollection = dataset->GetEventCollection(Types::kTesting);
mvaResWeights.reserve(eventCollection.size());
for (auto ev : eventCollection) {
    mvaResWeights.push_back(ev->GetWeight());
}

rocCurve = new TMVA::ROCCurve(*mvaRes, *mvaResTypes, mvaResWeights);

```

And from rocCurve you can get the requested sensitivity and specificity.

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![divyakuttan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/ba8739/32.png) [@divyakuttan](https://root-forum.cern.ch/u/divyakuttan)\
**Post date:** [August 6, 2018, 7:43am UTC](https://root-forum.cern.ch/t/getting-the-sensitivty-and-specificity-array/30105/5 "2018-08-06T07:43:41Z")

</div>

Hi,

Thank you so much for the reply. But unfortunately that didn’t work in my code. Should I put this directly to the code or to the ROCCurve .cxx file.

---

<div class="post-metadata">

**Author:** ![kialbert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kialbert/32/16537_2.png) [@kialbert](https://root-forum.cern.ch/u/kialbert)\
**Post date:** [August 7, 2018, 1:46pm UTC](https://root-forum.cern.ch/t/getting-the-sensitivty-and-specificity-array/30105/6 "2018-08-07T13:46:46Z")

</div>

It should be put in your code.

Basically the idea is to get the vector of results from the method. To do this we need to get the dataset (where the input and output to/from methods are stored). We then need to convert the results to a format that the ROCCurve class understands and finally construct the ROCCurve.

Cheers,  
Kim
