10000 Merge pull request #4171 from amueller/statistical_learning_gridsearch · scikit-learn/scikit-learn@25db1ac · GitHub
[go: up one dir, main page]

Skip to content

Commit 25db1ac

Browse files
committed
Merge pull request #4171 from amueller/statistical_learning_gridsearch
DOC: search C not gamma of linear svm in tutorial
2 parents cee2217 + e936dfa commit 25db1ac

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

doc/tutorial/statistical_inference/model_selection.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,19 @@ parameters to maximize the cross-validation score. This object takes an
140140
estimator during the construction and exposes an estimator API::
141141

142142
>>> from sklearn.grid_search import GridSearchCV
143-
>>> gammas = np.logspace(-6, -1, 10)
144-
>>> clf = GridSearchCV(estimator=svc, param_grid=dict(gamma=gammas),
143+
>>> Cs = np.logspace(-6, -1, 10)
144+
>>> clf = GridSearchCV(estimator=svc, param_grid=dict(C=Cs),
145145
... n_jobs=-1)
146146
>>> clf.fit(X_digits[:1000], y_digits[:1000]) # doctest: +ELLIPSIS
147147
GridSearchCV(cv=None,...
148148
>>> clf.best_score_ # doctest: +ELLIPSIS
149-
0.924...
150-
>>> clf.best_estimator_.gamma == 1e-6
151-
True
149+
0.925...
150+
>>> clf.best_estimator_.C # doctest: +ELLIPSIS
151+
0.0077...
152152

153153
>>> # Prediction performance on test set is not as good as on train set
154-
>>> clf.score(X_digits[1000:], y_digits[1000:])
155-
0.94228356336260977
154+
>>> clf.score(X_digits[1000:], y_digits[1000:]) # doctest: +ELLIPSIS
155+
0.943...
156156

157157

158158
By default, the :class:`GridSearchCV` uses a 3-fold cross-validation. However,
@@ -165,7 +165,7 @@ a stratified 3-fold.
165165

166166
>>> cross_validation.cross_val_score(clf, X_digits, y_digits)
167167
... # doctest: +ELLIPSIS
168-
array([ 0.935..., 0.958..., 0.937...])
168+
array([ 0.938..., 0.963..., 0.944...])
169169

170170
Two cross-validation loops are performed in parallel: one by the
171171
:class:`GridSearchCV` estimator to set ``gamma`` and the other one by

0 commit comments

Comments
 (0)
0