Skip to content

Commit

Permalink
update notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
jmduarte committed Apr 12, 2024
1 parent 5b6cbbf commit 921b832
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions notebooks/02_Tabular_Data_BDT.ipynb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -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": {},
Expand Down Expand Up @@ -663,7 +702,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.9.5"
},
"vscode": {
"interpreter": {
Expand Down

0 comments on commit 921b832

Please sign in to comment.