Merge pull request #169 from rickiepark/params_for_warn_and_perf

Params for warn and perf
main
Aurélien Geron 2018-02-06 17:09:13 +01:00 committed by GitHub
commit a4c4c714eb
3 changed files with 9 additions and 9 deletions

View File

@ -1503,7 +1503,7 @@
"forest_reg = RandomForestRegressor(random_state=42)\n", "forest_reg = RandomForestRegressor(random_state=42)\n",
"# train across 5 folds, that's a total of (12+6)*5=90 rounds of training \n", "# train across 5 folds, that's a total of (12+6)*5=90 rounds of training \n",
"grid_search = GridSearchCV(forest_reg, param_grid, cv=5,\n", "grid_search = GridSearchCV(forest_reg, param_grid, cv=5,\n",
" scoring='neg_mean_squared_error')\n", " scoring='neg_mean_squared_error', return_train_score=True)\n",
"grid_search.fit(housing_prepared, housing_labels)" "grid_search.fit(housing_prepared, housing_labels)"
] ]
}, },

View File

@ -241,7 +241,7 @@
"source": [ "source": [
"from sklearn.linear_model import SGDClassifier\n", "from sklearn.linear_model import SGDClassifier\n",
"\n", "\n",
"sgd_clf = SGDClassifier(random_state=42)\n", "sgd_clf = SGDClassifier(max_iter=5, random_state=42)\n",
"sgd_clf.fit(X_train, y_train_5)" "sgd_clf.fit(X_train, y_train_5)"
] ]
}, },
@ -766,7 +766,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"from sklearn.multiclass import OneVsOneClassifier\n", "from sklearn.multiclass import OneVsOneClassifier\n",
"ovo_clf = OneVsOneClassifier(SGDClassifier(random_state=42))\n", "ovo_clf = OneVsOneClassifier(SGDClassifier(max_iter=5, random_state=42))\n",
"ovo_clf.fit(X_train, y_train)\n", "ovo_clf.fit(X_train, y_train)\n",
"ovo_clf.predict([some_digit])" "ovo_clf.predict([some_digit])"
] ]
@ -948,7 +948,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"y_train_knn_pred = cross_val_predict(knn_clf, X_train, y_multilabel, cv=3)\n", "y_train_knn_pred = cross_val_predict(knn_clf, X_train, y_multilabel, cv=3, n_jobs=-1)\n",
"f1_score(y_multilabel, y_train_knn_pred, average=\"macro\")" "f1_score(y_multilabel, y_train_knn_pred, average=\"macro\")"
] ]
}, },
@ -1185,7 +1185,7 @@
"param_grid = [{'weights': [\"uniform\", \"distance\"], 'n_neighbors': [3, 4, 5]}]\n", "param_grid = [{'weights': [\"uniform\", \"distance\"], 'n_neighbors': [3, 4, 5]}]\n",
"\n", "\n",
"knn_clf = KNeighborsClassifier()\n", "knn_clf = KNeighborsClassifier()\n",
"grid_search = GridSearchCV(knn_clf, param_grid, cv=5, verbose=3)\n", "grid_search = GridSearchCV(knn_clf, param_grid, cv=5, verbose=3, n_jobs=-1)\n",
"grid_search.fit(X_train, y_train)" "grid_search.fit(X_train, y_train)"
] ]
}, },

View File

@ -452,7 +452,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"from sklearn.linear_model import SGDRegressor\n", "from sklearn.linear_model import SGDRegressor\n",
"sgd_reg = SGDRegressor(n_iter=50, penalty=None, eta0=0.1, random_state=42)\n", "sgd_reg = SGDRegressor(max_iter=50, penalty=None, eta0=0.1, random_state=42)\n",
"sgd_reg.fit(X, y.ravel())" "sgd_reg.fit(X, y.ravel())"
] ]
}, },
@ -880,7 +880,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"sgd_reg = SGDRegressor(penalty=\"l2\", random_state=42)\n", "sgd_reg = SGDRegressor(max_iter=5, penalty=\"l2\", random_state=42)\n",
"sgd_reg.fit(X, y.ravel())\n", "sgd_reg.fit(X, y.ravel())\n",
"sgd_reg.predict([[1.5]])" "sgd_reg.predict([[1.5]])"
] ]
@ -981,7 +981,7 @@
"X_train_poly_scaled = poly_scaler.fit_transform(X_train)\n", "X_train_poly_scaled = poly_scaler.fit_transform(X_train)\n",
"X_val_poly_scaled = poly_scaler.transform(X_val)\n", "X_val_poly_scaled = poly_scaler.transform(X_val)\n",
"\n", "\n",
"sgd_reg = SGDRegressor(n_iter=1,\n", "sgd_reg = SGDRegressor(max_iter=1,\n",
" penalty=None,\n", " penalty=None,\n",
" eta0=0.0005,\n", " eta0=0.0005,\n",
" warm_start=True,\n", " warm_start=True,\n",
@ -1030,7 +1030,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"from sklearn.base import clone\n", "from sklearn.base import clone\n",
"sgd_reg = SGDRegressor(n_iter=1, warm_start=True, penalty=None,\n", "sgd_reg = SGDRegressor(max_iter=1, warm_start=True, penalty=None,\n",
" learning_rate=\"constant\", eta0=0.0005, random_state=42)\n", " learning_rate=\"constant\", eta0=0.0005, random_state=42)\n",
"\n", "\n",
"minimum_val_error = float(\"inf\")\n", "minimum_val_error = float(\"inf\")\n",