Scikit-Learn 0.19 Pipelines expect a list of tuples, not a tuple of tuples

main
Aurélien Geron 2017-09-15 18:12:27 +02:00
parent 134a10e4d2
commit 26d79edcda
1 changed files with 16 additions and 16 deletions

View File

@ -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",