{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Correlation Matrix" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This example illustrates how to create a correlation matrix between input variables." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "\n", "from freeforestml import Variable, correlation_matrix\n", "from freeforestml import toydata, example_style\n", "example_style()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = toydata.get()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "v_higgs_m = Variable(r\"$m^H$\", \"higgs_m\", \"GeV\")\n", "v_jet_1_pt = Variable(r\"$p_{\\mathrm{T}}^{j_1}$\", \"jet_1_pt\", \"GeV\")\n", "v_jet_2_pt = Variable(r\"$p_{\\mathrm{T}}^{j_2}$\", \"jet_2_pt\", \"GeV\")\n", "v_m_jj = Variable(r\"$m^{jj}$\", \"m_jj\", \"GeV\")\n", "v_jet_1_eta = Variable(r\"$\\eta^{j_1}$\" ,\"jet_1_eta\") \n", "v_jet_2_eta = Variable(r\"$\\eta^{j_2}$\" ,\"jet_2_eta\")\n", "v_tau_pt = Variable(r\"$p_{\\mathrm{T}}^{\\tau}$\", \"tau_pt\", \"GeV\")\n", "v_lep_pt = Variable(r\"$p_{\\mathrm{T}}^{\\ell}$\", \"lep_pt\", \"GeV\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "fig, axes = plt.subplots(figsize=(5, 4.5))\n", "correlation_matrix(df, [v_jet_1_pt, v_jet_2_pt, v_m_jj, v_higgs_m,\n", " v_tau_pt, v_lep_pt, v_jet_1_eta, v_jet_2_eta],\n", " figure=fig, axes=axes)" ] } ], "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 }