Versicolor instead of Versicolour

main
Aurélien Geron 2017-02-17 14:47:18 +01:00
parent df5905884b
commit fc6fd7e610
3 changed files with 11 additions and 11 deletions

View File

@ -1245,7 +1245,7 @@
"\n", "\n",
"plt.figure(figsize=(10, 4))\n", "plt.figure(figsize=(10, 4))\n",
"plt.plot(X[y==2, 0], X[y==2, 1], \"g^\", label=\"Iris-Virginica\")\n", "plt.plot(X[y==2, 0], X[y==2, 1], \"g^\", label=\"Iris-Virginica\")\n",
"plt.plot(X[y==1, 0], X[y==1, 1], \"bs\", label=\"Iris-Versicolour\")\n", "plt.plot(X[y==1, 0], X[y==1, 1], \"bs\", label=\"Iris-Versicolor\")\n",
"plt.plot(X[y==0, 0], X[y==0, 1], \"yo\", label=\"Iris-Setosa\")\n", "plt.plot(X[y==0, 0], X[y==0, 1], \"yo\", label=\"Iris-Setosa\")\n",
"\n", "\n",
"from matplotlib.colors import ListedColormap\n", "from matplotlib.colors import ListedColormap\n",

View File

@ -100,9 +100,9 @@
"X = iris[\"data\"][:, (2, 3)] # petal length, petal width\n", "X = iris[\"data\"][:, (2, 3)] # petal length, petal width\n",
"y = iris[\"target\"]\n", "y = iris[\"target\"]\n",
"\n", "\n",
"setosa_or_versicolour = (y == 0) | (y == 1)\n", "setosa_or_versicolor = (y == 0) | (y == 1)\n",
"X = X[setosa_or_versicolour]\n", "X = X[setosa_or_versicolor]\n",
"y = y[setosa_or_versicolour]\n", "y = y[setosa_or_versicolor]\n",
"\n", "\n",
"# SVM Classifier model\n", "# SVM Classifier model\n",
"svm_clf = SVC(kernel=\"linear\", C=float(\"inf\"))\n", "svm_clf = SVC(kernel=\"linear\", C=float(\"inf\"))\n",
@ -150,7 +150,7 @@
"plt.plot(x0, pred_1, \"g--\", linewidth=2)\n", "plt.plot(x0, pred_1, \"g--\", linewidth=2)\n",
"plt.plot(x0, pred_2, \"m-\", linewidth=2)\n", "plt.plot(x0, pred_2, \"m-\", linewidth=2)\n",
"plt.plot(x0, pred_3, \"r-\", linewidth=2)\n", "plt.plot(x0, pred_3, \"r-\", linewidth=2)\n",
"plt.plot(X[:, 0][y==1], X[:, 1][y==1], \"bs\", label=\"Iris-Versicolour\")\n", "plt.plot(X[:, 0][y==1], X[:, 1][y==1], \"bs\", label=\"Iris-Versicolor\")\n",
"plt.plot(X[:, 0][y==0], X[:, 1][y==0], \"yo\", label=\"Iris-Setosa\")\n", "plt.plot(X[:, 0][y==0], X[:, 1][y==0], \"yo\", label=\"Iris-Setosa\")\n",
"plt.xlabel(\"Petal length\", fontsize=14)\n", "plt.xlabel(\"Petal length\", fontsize=14)\n",
"plt.ylabel(\"Petal width\", fontsize=14)\n", "plt.ylabel(\"Petal width\", fontsize=14)\n",
@ -373,7 +373,7 @@
"plt.figure(figsize=(12,3.2))\n", "plt.figure(figsize=(12,3.2))\n",
"plt.subplot(121)\n", "plt.subplot(121)\n",
"plt.plot(X[:, 0][y==1], X[:, 1][y==1], \"g^\", label=\"Iris-Virginica\")\n", "plt.plot(X[:, 0][y==1], X[:, 1][y==1], \"g^\", label=\"Iris-Virginica\")\n",
"plt.plot(X[:, 0][y==0], X[:, 1][y==0], \"bs\", label=\"Iris-Versicolour\")\n", "plt.plot(X[:, 0][y==0], X[:, 1][y==0], \"bs\", label=\"Iris-Versicolor\")\n",
"plot_svc_decision_boundary(svm_clf1, 4, 6)\n", "plot_svc_decision_boundary(svm_clf1, 4, 6)\n",
"plt.xlabel(\"Petal length\", fontsize=14)\n", "plt.xlabel(\"Petal length\", fontsize=14)\n",
"plt.ylabel(\"Petal width\", fontsize=14)\n", "plt.ylabel(\"Petal width\", fontsize=14)\n",

View File

@ -159,7 +159,7 @@
" plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)\n", " plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)\n",
" if plot_training:\n", " if plot_training:\n",
" plt.plot(X[:, 0][y==0], X[:, 1][y==0], \"yo\", label=\"Iris-Setosa\")\n", " plt.plot(X[:, 0][y==0], X[:, 1][y==0], \"yo\", label=\"Iris-Setosa\")\n",
" plt.plot(X[:, 0][y==1], X[:, 1][y==1], \"bs\", label=\"Iris-Versicolour\")\n", " plt.plot(X[:, 0][y==1], X[:, 1][y==1], \"bs\", label=\"Iris-Versicolor\")\n",
" plt.plot(X[:, 0][y==2], X[:, 1][y==2], \"g^\", label=\"Iris-Virginica\")\n", " plt.plot(X[:, 0][y==2], X[:, 1][y==2], \"g^\", label=\"Iris-Virginica\")\n",
" plt.axis(axes)\n", " plt.axis(axes)\n",
" if iris:\n", " if iris:\n",
@ -241,7 +241,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"X[(X[:, 1]==X[:, 1][y==1].max()) & (y==1)] # widest Iris-Versicolour flower" "X[(X[:, 1]==X[:, 1][y==1].max()) & (y==1)] # widest Iris-Versicolor flower"
] ]
}, },
{ {
@ -254,9 +254,9 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"not_widest_versicolour = (X[:, 1]!=1.8) | (y==2)\n", "not_widest_versicolor = (X[:, 1]!=1.8) | (y==2)\n",
"X_tweaked = X[not_widest_versicolour]\n", "X_tweaked = X[not_widest_versicolor]\n",
"y_tweaked = y[not_widest_versicolour]\n", "y_tweaked = y[not_widest_versicolor]\n",
"\n", "\n",
"tree_clf_tweaked = DecisionTreeClassifier(max_depth=2, random_state=40)\n", "tree_clf_tweaked = DecisionTreeClassifier(max_depth=2, random_state=40)\n",
"tree_clf_tweaked.fit(X_tweaked, y_tweaked)" "tree_clf_tweaked.fit(X_tweaked, y_tweaked)"