From 1714a5d6751e6dc8097681d1d60264581a13dc28 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 1 May 2024 15:57:29 +0200 Subject: [PATCH] :art: latest colab image has finally pandas 2 (2.0.3) - restriction on matplotlib version not needed anymore - :art: shorten "principal comentent" to PC --- docs/tutorial/log_reg.ipynb | 28 ++++++++++++---------------- docs/tutorial/log_reg.py | 4 ++-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/docs/tutorial/log_reg.ipynb b/docs/tutorial/log_reg.ipynb index c3b1f1c..af21d22 100644 --- a/docs/tutorial/log_reg.ipynb +++ b/docs/tutorial/log_reg.ipynb @@ -27,8 +27,7 @@ "source": [ "# Setup colab installation\n", "# You need to restart the runtime after running this cell\n", - "# (due to a pandas 1.5.3 and matplotlib >3.7 incompability - 23-11-07)\n", - "%pip install njab heatmapz openpyxl \"matplotlib<3.7\" plotly" + "%pip install njab heatmapz openpyxl plotly" ] }, { @@ -47,32 +46,28 @@ "from pathlib import Path\n", "from typing import Optional\n", "\n", - "from IPython.display import display\n", - "\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", - "\n", "import plotly.express as px\n", - "import matplotlib.pyplot as plt\n", "import seaborn\n", - "from heatmap import corrplot\n", - "import umap\n", - "\n", "import sklearn\n", "import sklearn.impute\n", - "from sklearn.metrics import make_scorer, log_loss\n", "import statsmodels.api as sm\n", + "import umap\n", + "from heatmap import corrplot\n", + "from IPython.display import display\n", + "from sklearn.metrics import log_loss, make_scorer\n", "\n", "import njab.sklearn\n", + "from njab.plotting.metrics import plot_auc, plot_prc\n", "from njab.sklearn import StandardScaler\n", "from njab.sklearn import pca as njab_pca\n", - "from njab.sklearn.scoring import ConfusionMatrix\n", + "from njab.sklearn.scoring import (ConfusionMatrix,\n", + " get_lr_multiplicative_decomposition,\n", + " get_pred, get_score,\n", + " get_target_count_per_bin)\n", "from njab.sklearn.types import Splits\n", - "from njab.plotting.metrics import plot_auc, plot_prc\n", - "from njab.sklearn.scoring import (get_score,\n", - " get_pred,\n", - " get_target_count_per_bin,\n", - " get_lr_multiplicative_decomposition)\n", "\n", "logger = logging.getLogger('njab')\n", "logger.setLevel(logging.INFO)\n", @@ -588,6 +583,7 @@ "files_out['scatter_first_5PCs.pdf'] = FOLDER / 'scatter_first_5PCs.pdf'\n", "\n", "fig, axes = plt.subplots(5, 2, figsize=(6, 8), layout='constrained')\n", + "PCs.columns = [s.replace(\"principal component\", \"PC\") for s in PCs.columns]\n", "PCs = PCs.join(y.astype('category'))\n", "up_to = min(PCs.shape[-1], 5)\n", "# https://github.com/matplotlib/matplotlib/issues/25538\n", diff --git a/docs/tutorial/log_reg.py b/docs/tutorial/log_reg.py index 0e1fad2..0698116 100644 --- a/docs/tutorial/log_reg.py +++ b/docs/tutorial/log_reg.py @@ -25,8 +25,7 @@ # %% tags=["hide-output"] # Setup colab installation # You need to restart the runtime after running this cell -# (due to a pandas 1.5.3 and matplotlib >3.7 incompability - 23-11-07) -# %pip install njab heatmapz openpyxl "matplotlib<3.7" plotly +# %pip install njab heatmapz openpyxl plotly # %% tags=["hide-input"] import itertools @@ -285,6 +284,7 @@ files_out['scatter_first_5PCs.pdf'] = FOLDER / 'scatter_first_5PCs.pdf' fig, axes = plt.subplots(5, 2, figsize=(6, 8), layout='constrained') +PCs.columns = [s.replace("principal component", "PC") for s in PCs.columns] PCs = PCs.join(y.astype('category')) up_to = min(PCs.shape[-1], 5) # https://github.com/matplotlib/matplotlib/issues/25538