From 519b3529d3509d86edb65114a60c26ca1d10d9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Wed, 20 Oct 2021 18:39:09 +1300 Subject: [PATCH] Clean up the beginning of the notebook --- 01_the_machine_learning_landscape.ipynb | 43 +++++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/01_the_machine_learning_landscape.ipynb b/01_the_machine_learning_landscape.ipynb index bb403f8..05776af 100644 --- a/01_the_machine_learning_landscape.ipynb +++ b/01_the_machine_learning_landscape.ipynb @@ -6,7 +6,7 @@ "source": [ "**Chapter 1 – The Machine Learning landscape**\n", "\n", - "_This contains the code example in this chapter 1, as well as all the code used to generate `lifesat.csv` and some of this chapter's figures._\n", + "_This notebook contains the code examples in chapter 1, as well as all the code used to generate `lifesat.csv` from the original data sources, and some of this chapter's figures._\n", "\n", "You're welcome to go through it if you want, but it's just a teaser: the real action starts in the next chapter." ] @@ -32,6 +32,13 @@ "# Setup" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Python 3.8 is required:" + ] + }, { "cell_type": "code", "execution_count": 1, @@ -42,11 +49,17 @@ }, "outputs": [], "source": [ - "# Python ≥3.8 is required\n", "import sys\n", "assert sys.version_info >= (3, 8)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Make this notebook's output stable across runs:" + ] + }, { "cell_type": "code", "execution_count": 2, @@ -55,28 +68,40 @@ "source": [ "import numpy as np\n", "\n", - "# Make this notebook's output stable across runs\n", "np.random.seed(42)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Scikit-Learn ≥1.0 is required:" + ] + }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ - "# Scikit-Learn ≥1.0 is required\n", "import sklearn\n", + "\n", "assert sklearn.__version__ >= \"1.0\"" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To plot pretty figures directly within Jupyter:" + ] + }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "# To plot pretty figures directly within Jupyter\n", "%matplotlib inline\n", "import matplotlib as mpl\n", "\n", @@ -84,13 +109,19 @@ "mpl.rc('axes', labelsize=14)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Download `lifesat.csv` from github, unless it's already available locally:" + ] + }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ - "# Download the data\n", "from pathlib import Path\n", "import urllib.request\n", "\n",