mirror of
https://github.com/ArthurDanjou/handson-ml3.git
synced 2026-01-14 12:14:36 +01:00
Improve a few figures (e.g., add missing labels, share axes, etc.)
This commit is contained in:
@@ -249,13 +249,14 @@
|
||||
"deep_tree_clf1.fit(Xm, ym)\n",
|
||||
"deep_tree_clf2.fit(Xm, ym)\n",
|
||||
"\n",
|
||||
"plt.figure(figsize=(11, 4))\n",
|
||||
"plt.subplot(121)\n",
|
||||
"plot_decision_boundary(deep_tree_clf1, Xm, ym, axes=[-1.5, 2.5, -1, 1.5], iris=False)\n",
|
||||
"fig, axes = plt.subplots(ncols=2, figsize=(10, 4), sharey=True)\n",
|
||||
"plt.sca(axes[0])\n",
|
||||
"plot_decision_boundary(deep_tree_clf1, Xm, ym, axes=[-1.5, 2.4, -1, 1.5], iris=False)\n",
|
||||
"plt.title(\"No restrictions\", fontsize=16)\n",
|
||||
"plt.subplot(122)\n",
|
||||
"plot_decision_boundary(deep_tree_clf2, Xm, ym, axes=[-1.5, 2.5, -1, 1.5], iris=False)\n",
|
||||
"plt.sca(axes[1])\n",
|
||||
"plot_decision_boundary(deep_tree_clf2, Xm, ym, axes=[-1.5, 2.4, -1, 1.5], iris=False)\n",
|
||||
"plt.title(\"min_samples_leaf = {}\".format(deep_tree_clf2.min_samples_leaf), fontsize=14)\n",
|
||||
"plt.ylabel(\"\")\n",
|
||||
"\n",
|
||||
"save_fig(\"min_samples_leaf_plot\")\n",
|
||||
"plt.show()"
|
||||
@@ -299,11 +300,12 @@
|
||||
"tree_clf_sr = DecisionTreeClassifier(random_state=42)\n",
|
||||
"tree_clf_sr.fit(Xsr, ys)\n",
|
||||
"\n",
|
||||
"plt.figure(figsize=(11, 4))\n",
|
||||
"plt.subplot(121)\n",
|
||||
"fig, axes = plt.subplots(ncols=2, figsize=(10, 4), sharey=True)\n",
|
||||
"plt.sca(axes[0])\n",
|
||||
"plot_decision_boundary(tree_clf_s, Xs, ys, axes=[-0.7, 0.7, -0.7, 0.7], iris=False)\n",
|
||||
"plt.subplot(122)\n",
|
||||
"plt.sca(axes[1])\n",
|
||||
"plot_decision_boundary(tree_clf_sr, Xsr, ys, axes=[-0.7, 0.7, -0.7, 0.7], iris=False)\n",
|
||||
"plt.ylabel(\"\")\n",
|
||||
"\n",
|
||||
"save_fig(\"sensitivity_to_rotation_plot\")\n",
|
||||
"plt.show()"
|
||||
@@ -365,8 +367,8 @@
|
||||
" plt.plot(X, y, \"b.\")\n",
|
||||
" plt.plot(x1, y_pred, \"r.-\", linewidth=2, label=r\"$\\hat{y}$\")\n",
|
||||
"\n",
|
||||
"plt.figure(figsize=(11, 4))\n",
|
||||
"plt.subplot(121)\n",
|
||||
"fig, axes = plt.subplots(ncols=2, figsize=(10, 4), sharey=True)\n",
|
||||
"plt.sca(axes[0])\n",
|
||||
"plot_regression_predictions(tree_reg1, X, y)\n",
|
||||
"for split, style in ((0.1973, \"k-\"), (0.0917, \"k--\"), (0.7718, \"k--\")):\n",
|
||||
" plt.plot([split, split], [-0.2, 1], style, linewidth=2)\n",
|
||||
@@ -376,7 +378,7 @@
|
||||
"plt.legend(loc=\"upper center\", fontsize=18)\n",
|
||||
"plt.title(\"max_depth=2\", fontsize=14)\n",
|
||||
"\n",
|
||||
"plt.subplot(122)\n",
|
||||
"plt.sca(axes[1])\n",
|
||||
"plot_regression_predictions(tree_reg2, X, y, ylabel=None)\n",
|
||||
"for split, style in ((0.1973, \"k-\"), (0.0917, \"k--\"), (0.7718, \"k--\")):\n",
|
||||
" plt.plot([split, split], [-0.2, 1], style, linewidth=2)\n",
|
||||
@@ -428,9 +430,9 @@
|
||||
"y_pred1 = tree_reg1.predict(x1)\n",
|
||||
"y_pred2 = tree_reg2.predict(x1)\n",
|
||||
"\n",
|
||||
"plt.figure(figsize=(11, 4))\n",
|
||||
"fig, axes = plt.subplots(ncols=2, figsize=(10, 4), sharey=True)\n",
|
||||
"\n",
|
||||
"plt.subplot(121)\n",
|
||||
"plt.sca(axes[0])\n",
|
||||
"plt.plot(X, y, \"b.\")\n",
|
||||
"plt.plot(x1, y_pred1, \"r.-\", linewidth=2, label=r\"$\\hat{y}$\")\n",
|
||||
"plt.axis([0, 1, -0.2, 1.1])\n",
|
||||
@@ -439,7 +441,7 @@
|
||||
"plt.legend(loc=\"upper center\", fontsize=18)\n",
|
||||
"plt.title(\"No restrictions\", fontsize=14)\n",
|
||||
"\n",
|
||||
"plt.subplot(122)\n",
|
||||
"plt.sca(axes[1])\n",
|
||||
"plt.plot(X, y, \"b.\")\n",
|
||||
"plt.plot(x1, y_pred2, \"r.-\", linewidth=2, label=r\"$\\hat{y}$\")\n",
|
||||
"plt.axis([0, 1, -0.2, 1.1])\n",
|
||||
@@ -720,7 +722,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.6.8"
|
||||
"version": "3.7.4"
|
||||
},
|
||||
"nav_menu": {
|
||||
"height": "309px",
|
||||
|
||||
Reference in New Issue
Block a user