Home | News | Documentation | Download

Extract information from TMVA output file (TMVA.root by default)


So I’m trying to reproduce some stuff on old TMVA training. I’ve got the TMVA output file, TMVA.root, but it seems there are no ready made functions to do just that (or I can’t seem to grasp the TMVA API).

I’ve opened the file and it contains the TMVA::DataLoader object I presume populated by the TMVA::Factory and I can browse it fully. I can see all the models with their weights, training epoch history, etc., and even the train and test trees with all entries. However, I cannot for some reason open that data up in something useful and extract the TMVA performance plots back.

For example, I would like to call something like:

void tmva_plot(std::string infilename) {
    // don't change the order of the function calls, some don't
    // work otherwise (no idea why)

    // HistType 3 is overtraining plot
    auto myFile = std::unique_ptr<TFile>(TFile::Open(infilename.c_str()));
    std::cout << myFile->GetName() << std::endl;
    // TMVA::DataLoader("dataset");  // does not work for some reason
    TMVA::mvas("dataset", infilename, static_cast<TMVA::HistType>(3));
    // TMVA::mvaeffs("dataset", infilename);  // currently has a bug
    TMVA::efficiencies("dataset", infilename);
    TMVA::correlations("dataset", infilename);
    TMVA::variables("dataset", infilename);

which mostly works, but I cannot specify anything about the plot parameters I get. I would like to get the ROC curve comparison between all the 4 MVAs stored and zoom on the histograms in the high region. I tried manually doing this, but the histogram is stored with just the 100 bins, so I would need to re-evaluate the models over the stored events in the test tree, but I’m not sure how to load the models at all or do that. The docs over here ROOT: TMVA Namespace Reference are not very clear at least to me. The User Guide was also not a huge help. Any pointers will be much appreciated. Thanks in advance!

I guess @moneta can help.


Will be the TMVAGui helpful for you ? By doing TMVA::TMVAGui(TMVA.root) you can make the plot you like.
With the histogram editor you might be able to perform some changes in the histogram. If you want more customisation you would need to edit the corresponding functions defined in the tmva/tmvagui directory.
We are planning to modernise and improve the TMVA GUI and the way to make plots. If you have some specific requests, we will be interested to know more

Best regards