Scikit-Learn 0.19 expects lists in Pipelines, not tuples
parent
ca35dddc38
commit
134a10e4d2
|
@ -709,11 +709,11 @@
|
|||
" polybig_features = PolynomialFeatures(degree=degree, include_bias=False)\n",
|
||||
" std_scaler = StandardScaler()\n",
|
||||
" lin_reg = LinearRegression()\n",
|
||||
" polynomial_regression = Pipeline((\n",
|
||||
" polynomial_regression = Pipeline([\n",
|
||||
" (\"poly_features\", polybig_features),\n",
|
||||
" (\"std_scaler\", std_scaler),\n",
|
||||
" (\"lin_reg\", lin_reg),\n",
|
||||
" ))\n",
|
||||
" ])\n",
|
||||
" polynomial_regression.fit(X, y)\n",
|
||||
" y_newbig = polynomial_regression.predict(X_new)\n",
|
||||
" plt.plot(X_new, y_newbig, style, label=str(degree), linewidth=width)\n",
|
||||
|
@ -786,10 +786,10 @@
|
|||
"source": [
|
||||
"from sklearn.pipeline import Pipeline\n",
|
||||
"\n",
|
||||
"polynomial_regression = Pipeline((\n",
|
||||
"polynomial_regression = Pipeline([\n",
|
||||
" (\"poly_features\", PolynomialFeatures(degree=10, include_bias=False)),\n",
|
||||
" (\"lin_reg\", LinearRegression()),\n",
|
||||
" ))\n",
|
||||
" ])\n",
|
||||
"\n",
|
||||
"plot_learning_curves(polynomial_regression, X, y)\n",
|
||||
"plt.axis([0, 80, 0, 3]) # not shown\n",
|
||||
|
@ -829,11 +829,11 @@
|
|||
" for alpha, style in zip(alphas, (\"b-\", \"g--\", \"r:\")):\n",
|
||||
" model = model_class(alpha, **model_kargs) if alpha > 0 else LinearRegression()\n",
|
||||
" if polynomial:\n",
|
||||
" model = Pipeline((\n",
|
||||
" model = Pipeline([\n",
|
||||
" (\"poly_features\", PolynomialFeatures(degree=10, include_bias=False)),\n",
|
||||
" (\"std_scaler\", StandardScaler()),\n",
|
||||
" (\"regul_reg\", model),\n",
|
||||
" ))\n",
|
||||
" ])\n",
|
||||
" model.fit(X, y)\n",
|
||||
" y_new_regul = model.predict(X_new)\n",
|
||||
" lw = 2 if alpha > 0 else 1\n",
|
||||
|
@ -973,10 +973,10 @@
|
|||
"\n",
|
||||
"X_train, X_val, y_train, y_val = train_test_split(X[:50], y[:50].ravel(), test_size=0.5, random_state=10)\n",
|
||||
"\n",
|
||||
"poly_scaler = Pipeline((\n",
|
||||
"poly_scaler = Pipeline([\n",
|
||||
" (\"poly_features\", PolynomialFeatures(degree=90, include_bias=False)),\n",
|
||||
" (\"std_scaler\", StandardScaler()),\n",
|
||||
" ))\n",
|
||||
" ])\n",
|
||||
"\n",
|
||||
"X_train_poly_scaled = poly_scaler.fit_transform(X_train)\n",
|
||||
"X_val_poly_scaled = poly_scaler.transform(X_val)\n",
|
||||
|
|
Loading…
Reference in New Issue