Skip to content
Snippets Groups Projects

Resolve "TMVA example"

Merged Frank Sauerburger requested to merge 45-tmva-example into master
3 files
+ 960
0
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 62
0
%% Cell type:code id: tags:
``` python
import pandas as pd
import seaborn as sns
from nnfwtbn import Variable, Process, Cut, hist, McStack, DataStack, Stack, TmvaBdt
from nnfwtbn import toydata
```
%% Cell type:code id: tags:
``` python
df = toydata.get()
```
%% Cell type:markdown id: tags:
# Evaluation of TMVA BDT
The file `tmva_bdt.xml` contains a sample BDT trained on the toy dataset. The input variables are
- $\eta^{j_1}$,
- $\eta^{j_2}$,
- $\tau\;\mathrm{centrality}$ and
- $\ell\;\mathrm{centrality}$.
The BDT was trained with regular TMVA in ROOT. The weights stored in the XML file can be read by `nnfwtbn.TmvaBdt` directly.
%% Cell type:code id: tags:
``` python
bdt = TmvaBdt("tmva_bdt.xml")
df['bdt_prediction'] = bdt.predict(df)
```
%% Cell type:markdown id: tags:
# Plotting
%% Cell type:code id: tags:
``` python
p_ztt = Process(r"$Z\rightarrow\tau\tau$", range=(0, 0))
p_sig = Process(r"Signal", range=(1, 1))
```
%% Cell type:code id: tags:
``` python
colors = ["windows blue", "amber", "greyish", "faded green", "dusty purple"]
colors = sns.xkcd_palette(colors)
s_ztt = McStack(p_ztt, color=colors[0], histtype='step')
s_sig = McStack(p_sig, color=colors[1], histtype='step')
```
%% Cell type:code id: tags:
``` python
v_bdt = Variable("BDT Score", "bdt_prediction")
hist(df, v_bdt, 22, [s_ztt, s_sig], range=(-1.1, 1.1),
weight="weight", numerator=None)
None
```
Loading