mirror of
https://github.com/ArthurDanjou/handson-ml3.git
synced 2026-01-14 12:14:36 +01:00
Replace handson-ml2 with handson-ml3, and fix figure chapter numbers
This commit is contained in:
@@ -4,14 +4,14 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Chapter 5 – Decision Trees**"
|
||||
"**Chapter 6 – Decision Trees**"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"_This notebook contains all the sample code and solutions to the exercises in chapter 5._"
|
||||
"_This notebook contains all the sample code and solutions to the exercises in chapter 6._"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -20,10 +20,10 @@
|
||||
"source": [
|
||||
"<table align=\"left\">\n",
|
||||
" <td>\n",
|
||||
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml2/blob/master/06_decision_trees.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
|
||||
" <a href=\"https://colab.research.google.com/github/ageron/handson-ml3/blob/main/06_decision_trees.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
|
||||
" </td>\n",
|
||||
" <td>\n",
|
||||
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml2/blob/master/06_decision_trees.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
|
||||
" <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/ageron/handson-ml3/blob/main/06_decision_trees.ipynb\"><img src=\"https://kaggle.com/static/images/open-in-kaggle.svg\" /></a>\n",
|
||||
" </td>\n",
|
||||
"</table>"
|
||||
]
|
||||
@@ -146,7 +146,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**This code example generates Figure 5–1. Iris Decision Tree:**"
|
||||
"**This code example generates Figure 6–1. Iris Decision Tree:**"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -224,7 +224,7 @@
|
||||
" plt.plot(X_iris[:, 0][y_iris == idx], X_iris[:, 1][y_iris == idx],\n",
|
||||
" style, label=f\"Iris {name}\")\n",
|
||||
"\n",
|
||||
"# not in the book – this section beautifies and saves Figure 5–2\n",
|
||||
"# not in the book – this section beautifies and saves Figure 6–2\n",
|
||||
"tree_clf_deeper = DecisionTreeClassifier(max_depth=3, random_state=42)\n",
|
||||
"tree_clf_deeper.fit(X_iris, y_iris)\n",
|
||||
"th0, th1, th2a, th2b = tree_clf_deeper.tree_.threshold[[0, 2, 3, 6]]\n",
|
||||
@@ -339,7 +339,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# not in the book – this cell generates and saves Figure 5–3\n",
|
||||
"# not in the book – this cell generates and saves Figure 6–3\n",
|
||||
"\n",
|
||||
"def plot_decision_boundary(clf, X, y, axes, cmap):\n",
|
||||
" x1, x2 = np.meshgrid(np.linspace(axes[0], axes[1], 100),\n",
|
||||
@@ -480,7 +480,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# not in the book – this cell generates and saves Figure 5–5\n",
|
||||
"# not in the book – this cell generates and saves Figure 6–5\n",
|
||||
"\n",
|
||||
"def plot_regression_predictions(tree_reg, X, y, axes=[-0.5, 0.5, -0.05, 0.25]):\n",
|
||||
" x1 = np.linspace(axes[0], axes[1], 500).reshape(-1, 1)\n",
|
||||
@@ -524,7 +524,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# not in the book – this cell generates and saves Figure 5–6\n",
|
||||
"# not in the book – this cell generates and saves Figure 6–6\n",
|
||||
"\n",
|
||||
"tree_reg1 = DecisionTreeRegressor(random_state=42)\n",
|
||||
"tree_reg2 = DecisionTreeRegressor(random_state=42, min_samples_leaf=10)\n",
|
||||
@@ -577,7 +577,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# not in the book – this cell generates and saves Figure 5–7\n",
|
||||
"# not in the book – this cell generates and saves Figure 6–7\n",
|
||||
"\n",
|
||||
"np.random.seed(6)\n",
|
||||
"X_square = np.random.rand(100, 2) - 0.5\n",
|
||||
@@ -628,7 +628,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# not in the book – this cell generates and saves Figure 5–8\n",
|
||||
"# not in the book – this cell generates and saves Figure 6–8\n",
|
||||
"\n",
|
||||
"plt.figure(figsize=(8, 4))\n",
|
||||
"\n",
|
||||
@@ -691,7 +691,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# not in the book – this cell generates and saves Figure 5–9\n",
|
||||
"# not in the book – this cell generates and saves Figure 6–9\n",
|
||||
"\n",
|
||||
"plt.figure(figsize=(8, 4))\n",
|
||||
"y_pred = tree_clf_tweaked.predict(X_iris_all).reshape(lengths.shape)\n",
|
||||
|
||||
Reference in New Issue
Block a user