From 26d79edcda0e542153afd4487b3e6d04c8f666fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Fri, 15 Sep 2017 18:12:27 +0200 Subject: [PATCH] Scikit-Learn 0.19 Pipelines expect a list of tuples, not a tuple of tuples --- 05_support_vector_machines.ipynb | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/05_support_vector_machines.ipynb b/05_support_vector_machines.ipynb index bcf2ff1..24f9a5b 100644 --- a/05_support_vector_machines.ipynb +++ b/05_support_vector_machines.ipynb @@ -333,10 +333,10 @@ "X = iris[\"data\"][:, (2, 3)] # petal length, petal width\n", "y = (iris[\"target\"] == 2).astype(np.float64) # Iris-Virginica\n", "\n", - "svm_clf = Pipeline((\n", + "svm_clf = Pipeline([\n", " (\"scaler\", StandardScaler()),\n", " (\"linear_svc\", LinearSVC(C=1, loss=\"hinge\", random_state=42)),\n", - " ))\n", + " ])\n", "\n", "svm_clf.fit(X, y)" ] @@ -378,14 +378,14 @@ "svm_clf1 = LinearSVC(C=1, loss=\"hinge\", random_state=42)\n", "svm_clf2 = LinearSVC(C=100, loss=\"hinge\", random_state=42)\n", "\n", - "scaled_svm_clf1 = Pipeline((\n", + "scaled_svm_clf1 = Pipeline([\n", " (\"scaler\", scaler),\n", " (\"linear_svc\", svm_clf1),\n", - " ))\n", - "scaled_svm_clf2 = Pipeline((\n", + " ])\n", + "scaled_svm_clf2 = Pipeline([\n", " (\"scaler\", scaler),\n", " (\"linear_svc\", svm_clf2),\n", - " ))\n", + " ])\n", "\n", "scaled_svm_clf1.fit(X, y)\n", "scaled_svm_clf2.fit(X, y)" @@ -544,11 +544,11 @@ "from sklearn.pipeline import Pipeline\n", "from sklearn.preprocessing import PolynomialFeatures\n", "\n", - "polynomial_svm_clf = Pipeline((\n", + "polynomial_svm_clf = Pipeline([\n", " (\"poly_features\", PolynomialFeatures(degree=3)),\n", " (\"scaler\", StandardScaler()),\n", " (\"svm_clf\", LinearSVC(C=10, loss=\"hinge\", random_state=42))\n", - " ))\n", + " ])\n", "\n", "polynomial_svm_clf.fit(X, y)" ] @@ -592,10 +592,10 @@ "source": [ "from sklearn.svm import SVC\n", "\n", - "poly_kernel_svm_clf = Pipeline((\n", + "poly_kernel_svm_clf = Pipeline([\n", " (\"scaler\", StandardScaler()),\n", " (\"svm_clf\", SVC(kernel=\"poly\", degree=3, coef0=1, C=5))\n", - " ))\n", + " ])\n", "poly_kernel_svm_clf.fit(X, y)" ] }, @@ -609,10 +609,10 @@ }, "outputs": [], "source": [ - "poly100_kernel_svm_clf = Pipeline((\n", + "poly100_kernel_svm_clf = Pipeline([\n", " (\"scaler\", StandardScaler()),\n", " (\"svm_clf\", SVC(kernel=\"poly\", degree=10, coef0=100, C=5))\n", - " ))\n", + " ])\n", "poly100_kernel_svm_clf.fit(X, y)" ] }, @@ -739,10 +739,10 @@ }, "outputs": [], "source": [ - "rbf_kernel_svm_clf = Pipeline((\n", + "rbf_kernel_svm_clf = Pipeline([\n", " (\"scaler\", StandardScaler()),\n", " (\"svm_clf\", SVC(kernel=\"rbf\", gamma=5, C=0.001))\n", - " ))\n", + " ])\n", "rbf_kernel_svm_clf.fit(X, y)" ] }, @@ -765,10 +765,10 @@ "\n", "svm_clfs = []\n", "for gamma, C in hyperparams:\n", - " rbf_kernel_svm_clf = Pipeline((\n", + " rbf_kernel_svm_clf = Pipeline([\n", " (\"scaler\", StandardScaler()),\n", " (\"svm_clf\", SVC(kernel=\"rbf\", gamma=gamma, C=C))\n", - " ))\n", + " ])\n", " rbf_kernel_svm_clf.fit(X, y)\n", " svm_clfs.append(rbf_kernel_svm_clf)\n", "\n",