21ROOT.TMVA.PyMethodBase.PyInitialize()
25modelFile =
"Higgs_trained_model.h5"
26if (ROOT.gSystem.AccessPathName(modelFile)) :
27 ROOT.Info(
"TMVA_SOFIE_RDataFrame",
"You need to run TMVA_Higgs_Classification.C to generate the Keras trained model")
32model = ROOT.TMVA.Experimental.SOFIE.PyKeras.Parse(modelFile)
34generatedHeaderFile =
"generatedSofieHiggsModel.hxx"
35print(
"Generating inference code for the Keras model from ",modelFile,
"in the header ", generatedHeaderFile)
38model.OutputGenerated(generatedHeaderFile)
42modelName = modelFile.replace(
".h5",
"")
43print(
"compiling SOFIE model ", modelName)
44ROOT.gInterpreter.Declare(
'#include "' + generatedHeaderFile +
'"')
47print(
"Generating inference code for the Keras model from ",modelFile,
"in the header ", generatedHeaderFile)
50inputFileName =
"Higgs_data.root"
51inputFile =
"http://root.cern.ch/files/" + inputFileName
60sigData = df1.AsNumpy(columns=[
'm_jj',
'm_jjj',
'm_lv',
'm_jlv',
'm_bb',
'm_wbb',
'm_wwbb'])
64xsig = np.column_stack(list(sigData.values()))
65dataset_size = xsig.shape[0]
66print(
"size of data", dataset_size)
69session = ROOT.TMVA_SOFIE_Higgs_trained_model.Session(
"generatedSofieHiggsModel.dat")
71hs = ROOT.TH1D(
"hs",
"Signal result",100,0,1)
72for i
in range(0,dataset_size):
73 result = session.infer(xsig[i,:])
79bkgData = df2.AsNumpy(columns=[
'm_jj',
'm_jjj',
'm_lv',
'm_jlv',
'm_bb',
'm_wbb',
'm_wwbb'])
81xbkg = np.column_stack(list(bkgData.values()))
82dataset_size = xbkg.shape[0]
84hb = ROOT.TH1D(
"hb",
"Background result",100,0,1)
85for i
in range(0,dataset_size):
86 result = session.infer(xbkg[i,:])
91ROOT.gStyle.SetOptStat(0)
92hs.SetLineColor(ROOT.kRed)
94hb.SetLineColor(ROOT.kBlue)
100print(
"Number of signal entries",hs.GetEntries())
101print(
"Number of background entries",hb.GetEntries())
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...