This macro provides an example of using a trained model with Keras and make inference using SOFIE and RDataFrame This macro uses as input a Keras model generated with the TMVA_Higgs_Classification.C tutorial You need to run that macro before to generate the trained Keras model Then you need to run the macro TMVA_SOFIE_Keras_HiggsModel.C to generate the corresponding header file using SOFIE.
Execute in this order:
root TMVA_Higgs_Classification.C
root TMVA_SOFIE_Keras_HiggsModel.C
root TMVA_SOFIE_RDataFrame.C
Author: Lorenzo Moneta
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Wednesday, April 17, 2024 at 11:22 AM.
using namespace TMVA::Experimental;
R__ADD_INCLUDE_PATH($PWD)
R__ADD_INCLUDE_PATH($ROOTSYS/runtutorials)
#include "Higgs_trained_model.hxx"
#include "TMVA/SOFIEHelpers.hxx"
using namespace TMVA::Experimental;
In file included from input_line_43:6: /home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master/documentation/doxygen/Higgs_trained_model.hxx:12:41: error: namespaces can only be defined in global or namespace scope namespace TMVA_SOFIE_Higgs_trained_model{ ^
Arguments are defined.
int nthreads = 2;
std::string inputFileName = "Higgs_data.root";
std::string inputFile = "http://root.cern.ch/files/" + inputFileName;
ROOT::EnableImplicitMT(nthreads);
ROOT::RDataFrame df1("sig_tree", inputFile);
int nslots = df1.GetNSlots();
std::cout << "Running using " << nslots << " threads" << std::endl;
auto h1 = df1.DefineSlot("DNN_Value", SofieFunctor<7, TMVA_SOFIE_Higgs_trained_model::Session>(nslots),
{"m_jj", "m_jjj", "m_lv", "m_jlv", "m_bb", "m_wbb", "m_wwbb"})
.Histo1D({"h_sig", "", 100, 0, 1}, "DNN_Value");
ROOT::RDataFrame df2("bkg_tree", inputFile);
nslots = df2.GetNSlots();
auto h2 = df2.DefineSlot("DNN_Value", SofieFunctor<7, TMVA_SOFIE_Higgs_trained_model::Session>(nslots),
{"m_jj", "m_jjj", "m_lv", "m_jlv", "m_bb", "m_wbb", "m_wwbb"})
.Histo1D({"h_bkg", "", 100, 0, 1}, "DNN_Value");
h1->SetLineColor(kRed);
h2->SetLineColor(kBlue);
auto c1 = new TCanvas();
gStyle->SetOptStat(0);
h2->DrawClone();
h1->DrawClone("SAME");
c1->BuildLegend();
input_line_53:10:55: error: 'TMVA_SOFIE_Higgs_trained_model' is not a class, namespace, or enumeration auto h1 = df1.DefineSlot("DNN_Value", SofieFunctor<7, TMVA_SOFIE_Higgs_trained_model::Session>(nslots), ^ input_line_53:10:55: note: 'TMVA_SOFIE_Higgs_trained_model' declared here input_line_53:16:55: error: use of undeclared identifier 'TMVA_SOFIE_Higgs_trained_model' auto h2 = df2.DefineSlot("DNN_Value", SofieFunctor<7, TMVA_SOFIE_Higgs_trained_model::Session>(nslots), ^ input_line_53:20:18: error: cannot take the address of an rvalue of type 'EColor' h1->SetLineColor(kRed); ^~~~ Error while creating dynamic expression for: <recovery-expr>(h1)->SetLineColor(kRed) input_line_53:21:18: error: cannot take the address of an rvalue of type 'EColor' h2->SetLineColor(kBlue); ^~~~~ Error while creating dynamic expression for: <recovery-expr>(h2)->SetLineColor(kBlue)