16variables = [
"Muon_pt_1",
"Muon_pt_2",
"Electron_pt_1",
"Electron_pt_2"]
20 """Reduce initial dataset to only events which shall be used for training"""
21 return df.Filter(
"nElectron>=2 && nMuon>=2",
"At least two electrons and two muons")
25 """Define the variables which shall be used for training"""
28 .Define(
"Muon_pt_1",
"Muon_pt[0]")
29 .Define(
"Muon_pt_2",
"Muon_pt[1]")
30 .Define(
"Electron_pt_1",
"Electron_pt[0]")
31 .Define(
"Electron_pt_2",
"Electron_pt[1]")
36 """Load, filter, define variables, and add label column"""
37 filepath =
"root://eospublic.cern.ch//eos/root-eos/cms_opendata_2012_nanoaod/" + filename
41 df =
df.Define(
"label", f
"{label_value}.0")
46 """Load signal and background data"""
53 num_all = num_sig + num_bkg
60 columns=variables + [
"label",
"weight"],
81if __name__ ==
"__main__":
83 from xgboost
import XGBClassifier
85 X_train, y_train, w_train, X_test, y_test, w_test =
load_data()
87 print(f
"Training events: {X_train.shape[0]}")
88 print(f
"Testing events: {X_test.shape[0]}")
91 bdt.fit(X_train, y_train, sample_weight=w_train)
97 print(f
"Training done. ROC AUC: {auc:.4f}")
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 ,...