10000 FIX reuse len_cv instead of recalculating it · raghavrv/scikit-learn@b114063 · GitHub
[go: up one dir, main page]

Skip to content

Commit b114063

Browse files
committed
FIX reuse len_cv instead of recalculating it
1 parent 7df441c commit b114063

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sklearn/model_selection/search.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,16 +552,15 @@ def _fit(self, X, y, labels, parameter_iterable):
552552

553553
# Out is a list of triplet: score, estimator, n_test_samples
554554
n_fits = len(out)
555-
n_folds = cv.n_splits(X, y, labels)
556555

557556
scores = list()
558557
grid_scores = list()
559-
for grid_start in range(0, n_fits, n_folds):
558+
for grid_start in range(0, n_fits, len_cv):
560559
n_test_samples = 0
561560
score = 0
562561
all_scores = []
563562
for this_score, this_n_test_samples, _, parameters in \
564-
out[grid_start:grid_start + n_folds]:
563+
out[grid_start:grid_start + len_cv]:
565564
all_scores.append(this_score)
566565
if self.iid:
567566
this_score *= this_n_test_samples
@@ -570,7 +569,7 @@ def _fit(self, X, y, labels, parameter_iterable):
570569
if self.iid:
571570
score /= float(n_test_samples)
572571
else:
573-
score /= float(n_folds)
572+
score /= float(len_cv)
574573
scores.append((score, parameters))
575574
# TODO: shall we also store the test_fold_sizes?
576575
grid_scores.append(_CVScoreTuple(

0 commit comments

Comments
 (0)
0