Problems when using the TMVA::Reader->EvaluateMulticlass() method

Hi everyone!

I am trying to evaluate the multiclass scores in some code from some n-tuples. I have seen that for the case of binominal BDTs, there is a TMVA::Reader method called EvaluateMVA in which you can explicitly pass for each event, as an argument, a vector with the variables that the Reader needs.
Do you know if there is some equivalent way to do it with the EvaluateMulticlass method? Because none of the constructors take this vector of inputs as argument…
Is there any way to use the EvaluateMVA for a Multiclass classification?

Thanks a lot in advance,

Enrique

@moneta should be able to help

Thank you @bellenot @moneta !

Hi,
There is a Reader::EvaluateMultiClass, what you are missing is passing a std::vector<float> with the input features ?
This is not a very efficient API to use it, but if you need you can probably include these few lines in your code by setting the variables in the TMVA::Event class. Is there any reason that you cannot use the standard Reader API where you set the input variables using Reader::AddVariable ?

Lorenzo

Hello @moneta

Exactly, that would be my doubt: is such feature (passing a std::vector<float> with the input) available?
I have tried to add a TMVA::Event, but this does not seem to be used when calling EvaluateMulticlass. I have attached an example of the code implementing this TMVA::Event before calling the EvaluateMulticlass.

Enrique
TMVAMulticlassApplication_simple.C (1.7 KB)

Hi,

You cannot create an Event not attached to anything, but you need to use the one attached to the Method class. So you need first to get an instance to the used method (returned from Reader::BookMVA) and then from the class get the event and then fill the values.
You need to add these lines in your code

// need casting here from IMethod to MethodBase
auto methodBDTG = (TMVA::MethodBase*) reader->BookMVA( "BDTG method", "dataset/weights/TMVAMulticlass_BDTG.weights.xml");

// later in the event loop: 
// and we need to remove the const from the returned event:
auto event = const_cast<TMVA::Event*>(methodBDTG->GetEvent());
event->SetVal(0,....);
event->SetVal(1,....);

score = reader->EvaluateMulticlass( "BDTG method" );

If you have further problems please let me know

Cheers

Lorenzo