19from tmva100_DataPreparation
import variables
22def load_data(signal_filename, background_filename):
28 x_sig = np.vstack([data_sig[var]
for var
in variables]).T
29 x_bkg = np.vstack([data_bkg[var]
for var
in variables]).T
30 x = np.vstack([x_sig, x_bkg])
33 num_sig = x_sig.shape[0]
34 num_bkg = x_bkg.shape[0]
35 y = np.hstack([np.ones(num_sig), np.zeros(num_bkg)])
38 num_all = num_sig + num_bkg
39 w = np.hstack([np.ones(num_sig) * num_all / num_sig, np.ones(num_bkg) * num_all / num_bkg])
43if __name__ ==
"__main__":
45 x, y, w = load_data(
"train_signal.root",
"train_background.root")
48 from xgboost
import XGBClassifier
49 bdt = XGBClassifier(max_depth=3, n_estimators=500)
53 ROOT.TMVA.Experimental.SaveXGBoost(bdt,
"myBDT",
"tmva101.root")
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...