How to extract Cut Value?

Hi !
I’m doing some TMVA Boosted Decision Tree exercise and I’d like to save the Cut Value as a variable ? Basically the 0.019 variable. I couldn’t find the method to call.

— Factory : --------------------
— Factory : Method: Cut value:
— Factory : --------------------
— Factory : BDT: +0.019
— Factory : --------------------

Thanks !!


What is it that you want to achieve with this cut value one you have it and what is your configuration to produce the given output?


I’m looping over a different choice of train and test subsamples, and would like to compute the accuracy on the results by counting the true events I get. For that I would need the cut values I guess.

The factory configurations is: factory.BookMethod(TMVA.Types.kBDT, “BDT”, "BoostType=AdaBoost:"nCuts=20:"SeparationType=GiniIndex:“Ntrees=500:MaxDepth=3”).

Thanks !

I’m not sure I still understand what it is you want to do. Is the cut value presented as the cut value that optimises signal efficiency * purity?

Maybe this piece of code can help you calculate the accuracy of your classifier. Basically, you can loop over the results and calculate it for a given cut value manually.

UInt_t numEvents = ...;
TMVA::Factory factory = new Factory(...);

TMVA::IMethod * imethod = factory->GetMethod("datasetName", "methodName");
TMVA::MethodBase * method = dynamic_cast<MethodBase *>(imethod);

TMVA::DataSet * dataset = method->Data();
TMVA::DataSetInfo * dsi = method->DataInfo();
TMVA::Results * results = dataset->GetResults("methodName", TMVA::Types::kTesting, TMVA::Types::kClassification);

Double_t cutValue = 0.019;
UInt_t true_positives = 0;
UInt_t false_positives = 0;
UInt_t true_negatives = 0;
UInt_t false_negatives = 0;
for (UInt_t iEvent = 0; iEvent < numEvents; ++iEvent) {
    Double_t valueEvent = results[iEvent][0];
    TMVA::Event ev = dataset->GetEvent(iEvent, TMVA::Types::kTesting);
    if (valueEvent > cutValue) {
        // Event passed cut, consider it signal
        true_positives += dsi->IsSignal(ev); // True signal
        true_positives += not (dsi->IsSignal(ev)); // True background
    } else {
        // Event failed cut, consider it background
        false_negative += dsi->IsSignal(ev); // True signal
        true_negative += not (dsi->IsSignal(ev)); // True background

Hope this helps!


Yes, that is what I want to achieve but I need to extract the cutValue (0.019) automatically, through some
.GetCutValue -like method.

cheers, maffe.


I think this is what you are looking for

TMVA::IMethod * imethod = factory->GetMethod("datasetName", "methodName");
TMVA::MethodBase * method = dynamic_cast<MethodBase *>(imethod);

Double_t cut = method->GetSignalReferenceCut();

This is what is printed when EvaluateAllMethods is run.


Marvellous Kim.
cut = GetMethod(“BDT”).GetSignalReferenceCut()
was what I was looking for.


1 Like