Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust tutorial dependencies after colab image update #9

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions docs/tutorial/log_reg.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
28 changes: 12 additions & 16 deletions docs/tutorial/log_reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,36 @@
# %% 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
import logging
from pathlib import Path
from typing import Optional

from IPython.display import display

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

import plotly.express as px
import matplotlib.pyplot as plt
import seaborn
from heatmap import corrplot
import umap

import sklearn
import sklearn.impute
from sklearn.metrics import make_scorer, log_loss
import statsmodels.api as sm
import umap
from heatmap import corrplot
from IPython.display import display
from sklearn.metrics import log_loss, make_scorer

import njab.sklearn
from njab.plotting.metrics import plot_auc, plot_prc
from njab.sklearn import StandardScaler
from njab.sklearn import pca as njab_pca
from njab.sklearn.scoring import ConfusionMatrix
from njab.sklearn.scoring import (ConfusionMatrix,
get_lr_multiplicative_decomposition,
get_pred, get_score,
get_target_count_per_bin)
from njab.sklearn.types import Splits
from njab.plotting.metrics import plot_auc, plot_prc
from njab.sklearn.scoring import (get_score,
get_pred,
get_target_count_per_bin,
get_lr_multiplicative_decomposition)

logger = logging.getLogger('njab')
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -289,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
Expand Down