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 = modelFile.replace(
".h5",
".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 +
'"')
47generatedHeaderFile = modelFile.replace(
".h5",
".hxx")
48print(
"Generating inference code for the Keras model from ",modelFile,
"in the header ", generatedHeaderFile)
51inputFileName =
"Higgs_data.root"
52inputFile =
"http://root.cern.ch/files/" + inputFileName
61sigData = df1.AsNumpy(columns=[
'm_jj',
'm_jjj',
'm_lv',
'm_jlv',
'm_bb',
'm_wbb',
'm_wwbb'])
65xsig = np.column_stack(list(sigData.values()))
66dataset_size = xsig.shape[0]
67print(
"size of data", dataset_size)
70session = ROOT.TMVA_SOFIE_Higgs_trained_model.Session()
72hs = ROOT.TH1D(
"hs",
"Signal result",100,0,1)
73for i
in range(0,dataset_size):
74 result = session.infer(xsig[i,:])
80bkgData = df2.AsNumpy(columns=[
'm_jj',
'm_jjj',
'm_lv',
'm_jlv',
'm_bb',
'm_wbb',
'm_wwbb'])
82xbkg = np.column_stack(list(bkgData.values()))
83dataset_size = xbkg.shape[0]
85hb = ROOT.TH1D(
"hb",
"Background result",100,0,1)
86for i
in range(0,dataset_size):
87 result = session.infer(xbkg[i,:])
92ROOT.gStyle.SetOptStat(0)
93hs.SetLineColor(ROOT.kRed)
95hb.SetLineColor(ROOT.kBlue)
101print(
"Number of signal entries",hs.GetEntries())
102print(
"Number of background entries",hb.GetEntries())
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...