Skip to content

Commit 5bff742

Browse files
committed
COSMIT simplify printing of number of fits in grid search
1 parent c3f9739 commit 5bff742

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

sklearn/grid_search.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# License: BSD 3 clause
1212

1313
from abc import ABCMeta, abstractmethod
14-
from collections import Mapping, namedtuple
14+
from collections import Mapping, namedtuple, Sized
1515
from functools import partial, reduce
1616
from itertools import product
1717
import numbers
@@ -483,11 +483,8 @@ def _fit(self, X, y, parameter_iterable):
483483
cv = check_cv(cv, X, y, classifier=is_classifier(estimator))
484484

485485
if self.verbose > 0:
486-
try:
486+
if isinstance(parameter_iterable, Sized):
487487
n_candidates = len(parameter_iterable)
488-
except TypeError:
489-
pass
490-
else:
491488
print("Fitting {0} folds for each of {1} candidates, totalling"
492489
" {2} fits".format(len(cv), n_candidates,
493490
n_candidates * len(cv)))

0 commit comments

Comments
 (0)