From 921b8321d451e0ebd5189ae5fdb18fb0b251e0c9 Mon Sep 17 00:00:00 2001 From: Javier Duarte Date: Thu, 11 Apr 2024 21:41:30 -0700 Subject: [PATCH] update notebook --- notebooks/02_Tabular_Data_BDT.ipynb | 43 +++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/notebooks/02_Tabular_Data_BDT.ipynb b/notebooks/02_Tabular_Data_BDT.ipynb index ebbea74..281b16d 100644 --- a/notebooks/02_Tabular_Data_BDT.ipynb +++ b/notebooks/02_Tabular_Data_BDT.ipynb @@ -1,7 +1,6 @@ { "cells": [ { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -207,6 +206,46 @@ "print(f\"Fraction signal: {len(data[data.Label == 's'])/(len(data[data.Label == 's']) + len(data[data.Label == 'b']))}\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Visualize the features:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.figure()\n", + "\n", + "\n", + "fig, axs = plt.subplots(8, 4, figsize=(40, 80))\n", + "\n", + "for ix, ax in enumerate(axs.reshape(-1)):\n", + " col = data.columns[ix + 1]\n", + " if col == \"Weight\" or col == \"Label\":\n", + " continue\n", + " signal = data[col][data.Label == \"s\"].to_numpy()\n", + " mask_signal = signal > -999\n", + " background = data[col][data.Label == \"b\"].to_numpy()\n", + " mask_background = background > -999\n", + " xmin = min(np.min(background[mask_background]), np.min(signal[mask_signal]))\n", + " xmax = max(np.max(background[mask_background]), np.max(signal[mask_signal]))\n", + "\n", + " ax.hist(signal[mask_signal], bins=np.linspace(xmin, xmax, 51), alpha=0.5, label=\"signal\", density=True)\n", + " ax.hist(background[mask_background], bins=np.linspace(xmin, xmax, 51), alpha=0.5, label=\"background\", density=True)\n", + "\n", + " ax.set_xlabel(col, fontsize=40)\n", + " ax.set_xlabel(col, fontsize=40)\n", + " ax.tick_params(axis=\"both\", which=\"major\", labelsize=40)\n", + " ax.legend(fontsize=40)\n", + "plt.tight_layout()\n", + "plt.show()" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -663,7 +702,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.15" + "version": "3.9.5" }, "vscode": { "interpreter": {