From 6a46b65507fe41f961bdc09869e16c4a70190c22 Mon Sep 17 00:00:00 2001 From: Daniel Companeetz Date: Mon, 1 Sep 2025 21:56:16 -0700 Subject: [PATCH] Update Preamble and readme --- README.md | 16 ++++++++++++++++ preamble.py | 15 +++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d075436..3e1efc4 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,9 @@ the command ``pip install mglearn`` in your terminal or ``!pip install mglearn`` ## Errata + +### Missing import + Please note that the first print of the book is missing the following line when listing the assumed imports: ```python @@ -34,6 +37,19 @@ from IPython.display import display ``` Please add this line if you see an error involving ``display``. +### Spacy download language name changed +As of Spacy v3.0, the syntax is + +```python +python -m spacy download en_core_web_sm +``` + +### IPython.display.set_matplotlib_formats deprecated +See https://github.com/fangohr/introduction-to-python-for-computational-science-and-engineering/issues/32 + +[preamble.py](preamble.py) was adjusted to reflect the changes + +### Changes in sckit-learn from the first print The first print of the book used a function called ``plot_group_kfold``. This has been renamed to ``plot_label_kfold`` because of a rename in diff --git a/preamble.py b/preamble.py index 01a91be..7efaeab 100644 --- a/preamble.py +++ b/preamble.py @@ -1,11 +1,22 @@ -from IPython.display import set_matplotlib_formats, display +# Next is original line. +# see https://github.com/fangohr/introduction-to-python-for-computational-science-and-engineering/issues/32 +#from IPython.display import set_matplotlib_formats, display +from IPython.display import display import pandas as pd import numpy as np import matplotlib.pyplot as plt import mglearn from cycler import cycler -set_matplotlib_formats('pdf', 'png') +# New block per above url on set_matplotlib_formats problem +# settings for jupyter book: svg for html version, high-resolution png for pdf +import matplotlib_inline.backend_inline +# matplotlib_inline.backend_inline.set_matplotlib_formats('svg', 'png') +# import matplotlib as mpl +# mpl.rcParams['figure.dpi'] = 400 + +matplotlib_inline.backend_inline.set_matplotlib_formats('pdf', 'png') +#set_matplotlib_formats('pdf', 'png') plt.rcParams['savefig.dpi'] = 300 plt.rcParams['image.cmap'] = "viridis" plt.rcParams['image.interpolation'] = "none"