Skip to content

Commit cdae4a4

Browse files
committed
Merge pull request #4071 from amueller/grid_search_document_best_estimator
[MRG] Doc best_estimator_ depends on refit=True. Fixes #2976.
2 parents 69567ec + da8f672 commit cdae4a4

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

examples/model_selection/grid_search_digits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
print()
5252

5353
clf = GridSearchCV(SVC(C=1), tuned_parameters, cv=5,
54-
scoring='%_weighted' % score)
54+
scoring='%s_weighted' % score)
5555
clf.fit(X_train, y_train)
5656

5757
print("Best parameters set found on development set:")
5858
print()
59-
print(clf.best_estimator_)
59+
print(clf.best_params_)
6060
print()
6161
print("Grid scores on development set:")
6262
print()

sklearn/grid_search.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ class GridSearchCV(BaseSearchCV):
557557
fit_params : dict, optional
558558
Parameters to pass to the fit method.
559559
560-
n_jobs : int, optional
561-
Number of jobs to run in parallel (default 1).
560+
n_jobs : int, default 1
561+
Number of jobs to run in parallel.
562562
563563
pre_dispatch : int, or string, optional
564564
Controls the number of jobs that get dispatched during parallel
@@ -577,17 +577,17 @@ class GridSearchCV(BaseSearchCV):
577577
- A string, giving an expression as a function of n_jobs,
578578
as in '2*n_jobs'
579579
580-
iid : boolean, optional
580+
iid : boolean, default=True
581581
If True, the data is assumed to be identically distributed across
582582
the folds, and the loss minimized is the total loss per sample,
583583
and not the mean loss across the folds.
584584
585-
cv : integer or cross-validation generator, optional
586-
If an integer is passed, it is the number of folds (default 3).
585+
cv : integer or cross-validation generator, default=3
586+
If an integer is passed, it is the number of folds.
587587
Specific cross-validation objects can be passed, see
588588
sklearn.cross_validation module for the list of possible objects
589589
590-
refit : boolean
590+
refit : boolean, default=True
591591
Refit the best estimator with the entire dataset.
592592
If "False", it is impossible to make predictions using
593593
this GridSearchCV instance after fitting.
@@ -636,7 +636,7 @@ class GridSearchCV(BaseSearchCV):
636636
best_estimator_ : estimator
637637
Estimator that was chosen by the search, i.e. estimator
638638
which gave highest score (or smallest loss if specified)
639-
on the left out data.
639+
on the left out data. Not available if refit=False.
640640
641641
best_score_ : float
642642
Score of best_estimator on the left out data.
@@ -740,8 +740,8 @@ class RandomizedSearchCV(BaseSearchCV):
740740
fit_params : dict, optional
741741
Parameters to pass to the fit method.
742742
743-
n_jobs : int, optional
744-
Number of jobs to run in parallel (default 1).
743+
n_jobs : int, default=1
744+
Number of jobs to run in parallel.
745745
746746
pre_dispatch : int, or string, optional
747747
Controls the number of jobs that get dispatched during parallel
@@ -760,7 +760,7 @@ class RandomizedSearchCV(BaseSearchCV):
760760
- A string, giving an expression as a function of n_jobs,
761761
as in '2*n_jobs'
762762
763-
iid : boolean, optional
763+
iid : boolean, default=True
764764
If True, the data is assumed to be identically distributed across
765765
the folds, and the loss minimized is the total loss per sample,
766766
and not the mean loss across the folds.
@@ -770,7 +770,7 @@ class RandomizedSearchCV(BaseSearchCV):
770770
Specific cross-validation objects can be passed, see
771771
sklearn.cross_validation module for the list of possible objects
772772
773-
refit : boolean
773+
refit : boolean, default=True
774774
Refit the best estimator with the entire dataset.
775775
If "False", it is impossible to make predictions using
776776
this RandomizedSearchCV instance after fitting.
@@ -800,7 +800,7 @@ class RandomizedSearchCV(BaseSearchCV):
800800
best_estimator_ : estimator
801801
Estimator that was chosen by the search, i.e. estimator
802802
which gave highest score (or smallest loss if specified)
803-
on the left out data.
803+
on the left out data. Not available if refit=False.
804804
805805
best_score_ : float
806806
Score of best_estimator on the left out data.

0 commit comments

Comments
 (0)