28@contextlib.contextmanager
30 """Silence a known third-party warning. Raise if it stops firing.
32 Notifies us to drop the workaround once the upstream library is fixed.
45 f
"Expected {category.__name__} containing {message!r} was not "
46 "emitted. This tutorial's workaround can probably be removed."
53def CreateModel(nlayers=4, nunits=64):
57 for i
in range(1, nlayers):
61 model.compile(loss=
"binary_crossentropy", optimizer=
Adam(learning_rate=0.001), weighted_metrics=[
"accuracy"])
71 sigData =
df1.AsNumpy(columns=[
"m_jj",
"m_jjj",
"m_lv",
"m_jlv",
"m_bb",
"m_wbb",
"m_wwbb"])
77 print(
"size of data", data_sig_size)
81 bkgData =
df2.AsNumpy(columns=[
"m_jj",
"m_jjj",
"m_lv",
"m_jlv",
"m_bb",
"m_wbb",
"m_wwbb"])
92 x_train, x_test, y_train, y_test =
train_test_split(inputs_data, inputs_targets, test_size=0.50, random_state=1234)
94 return x_train, y_train, x_test, y_test
99 modelFile = name +
".keras"
104 ctx =
expect_warning(DeprecationWarning,
"__array__ implementation doesn't accept a copy keyword")
119model1 =
TrainModel(CreateModel(4, 64), x_train, y_train,
"Higgs_Model_4L_50")
120model2 =
TrainModel(CreateModel(4, 64), x_train, y_train,
"Higgs_Model_4L_200")
121model3 =
TrainModel(CreateModel(4, 64), x_train, y_train,
"Higgs_Model_2L_500")
129 print(
"Generating inference code for the Keras model from ", modelFile,
"in the header ", generatedHeaderFile)
135 return generatedHeaderFile
138generatedHeaderFile =
"Higgs_Model.hxx"
141 print(
"removing existing file", generatedHeaderFile)
144weightFile =
"Higgs_Model.root"
146 print(
"removing existing file", weightFile)
163hs1 =
ROOT.TH1D(
"hs1",
"Signal result 4L 50", 100, 0, 1)
164hs2 =
ROOT.TH1D(
"hs2",
"Signal result 4L 200", 100, 0, 1)
165hs3 =
ROOT.TH1D(
"hs3",
"Signal result 2L 500", 100, 0, 1)
167hb1 =
ROOT.TH1D(
"hb1",
"Background result 4L 50", 100, 0, 1)
168hb2 =
ROOT.TH1D(
"hb2",
"Background result 4L 200", 100, 0, 1)
169hb3 =
ROOT.TH1D(
"hb3",
"Background result 2L 500", 100, 0, 1)
178 result1 =
EvalModel(session1, x_test[i, :])
179 result2 =
EvalModel(session2, x_test[i, :])
180 result3 =
EvalModel(session3, x_test[i, :])
215 for i
in range(0, n):
222 xs, ws = GetContent(hs)
223 xb, wb = GetContent(hb)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...