ROC Curve

This notebook illustrates how to draw receiver operating characteristic curves (ROC) directly from a dataset.

[1]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

from freeforestml import Variable, Process, Cut, roc
from freeforestml import toydata, example_style
example_style()
2023-08-02 16:39:55.232856: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 AVX512F FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-08-02 16:39:55.364135: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2023-08-02 16:39:55.364191: I tensorflow/compiler/xla/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2023-08-02 16:39:56.181434: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2023-08-02 16:39:56.181542: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2023-08-02 16:39:56.181554: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
[2]:
df = toydata.get()
df['noise'] = df.fpid + 10 * (df.random - 0.5)**3
[3]:
p_bkg = Process(r"Background", range=(0, 0))
p_sig = Process(r"Signal", range=(1, 1))
[4]:
fig, ax = plt.subplots()

v_higgs_m = Variable(r"$m^H$", "higgs_m", "GeV")
roc(df.compute(), p_sig, p_bkg, v_higgs_m, axes=ax, steps=400)
roc(df.compute(), p_sig, p_bkg, Variable("Noise ID", "noise"), axes=ax, enlarge=1.5)
None
_images/ROC_5_0.png
[ ]: