{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ROC Curve" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook illustrates how to draw receiver operating characteristic curves (ROC) directly from a dataset." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "\n", "from freeforestml import Variable, Process, Cut, roc\n", "from freeforestml import toydata, example_style\n", "example_style()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = toydata.get()\n", "df['noise'] = df.fpid + 10 * (df.random - 0.5)**3" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "p_bkg = Process(r\"Background\", range=(0, 0))\n", "p_sig = Process(r\"Signal\", range=(1, 1))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots()\n", "\n", "v_higgs_m = Variable(r\"$m^H$\", \"higgs_m\", \"GeV\")\n", "roc(df.compute(), p_sig, p_bkg, v_higgs_m, axes=ax, steps=400)\n", "roc(df.compute(), p_sig, p_bkg, Variable(\"Noise ID\", \"noise\"), axes=ax, enlarge=1.5)\n", "None" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.2" } }, "nbformat": 4, "nbformat_minor": 2 }