commit
a4c4c714eb
|
@ -1503,7 +1503,7 @@
|
|||
"forest_reg = RandomForestRegressor(random_state=42)\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",
|
||||
" scoring='neg_mean_squared_error')\n",
|
||||
" scoring='neg_mean_squared_error', return_train_score=True)\n",
|
||||
"grid_search.fit(housing_prepared, housing_labels)"
|
||||
]
|
||||
},
|
||||
|
|
|
@ -241,7 +241,7 @@
|
|||
"source": [
|
||||
"from sklearn.linear_model import SGDClassifier\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)"
|
||||
]
|
||||
},
|
||||
|
@ -766,7 +766,7 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"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.predict([some_digit])"
|
||||
]
|
||||
|
@ -948,7 +948,7 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"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\")"
|
||||
]
|
||||
},
|
||||
|
@ -1185,7 +1185,7 @@
|
|||
"param_grid = [{'weights': [\"uniform\", \"distance\"], 'n_neighbors': [3, 4, 5]}]\n",
|
||||
"\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)"
|
||||
]
|
||||
},
|
||||
|
|
|
@ -452,7 +452,7 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"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())"
|
||||
]
|
||||
},
|
||||
|
@ -880,7 +880,7 @@
|
|||
},
|
||||
"outputs": [],
|
||||
"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.predict([[1.5]])"
|
||||
]
|
||||
|
@ -981,7 +981,7 @@
|
|||
"X_train_poly_scaled = poly_scaler.fit_transform(X_train)\n",
|
||||
"X_val_poly_scaled = poly_scaler.transform(X_val)\n",
|
||||
"\n",
|
||||
"sgd_reg = SGDRegressor(n_iter=1,\n",
|
||||
"sgd_reg = SGDRegressor(max_iter=1,\n",
|
||||
" penalty=None,\n",
|
||||
" eta0=0.0005,\n",
|
||||
" warm_start=True,\n",
|
||||
|
@ -1030,7 +1030,7 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"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",
|
||||
"\n",
|
||||
"minimum_val_error = float(\"inf\")\n",
|
||||
|
|
Loading…
Reference in New Issue