RFC try to warn on iid less often
@@ -821,7 +821,19 @@ class BaseSearchCV(six.with_metaclass(ABCMeta, BaseEstimator,
dtype=np.int)
iid = self.iid
if self.iid == 'warn':
- if len(np.unique(test_sample_counts)) > 1:
+ warn = False
+ for scorer_name in scorers.keys():
+ scores = test_scores[scorer_name].reshape(n_candidates,
+ n_splits)
+ means_weighted = np.average(scores, axis=1,
+ weights=test_sample_counts)
+ means_unweighted = np.average(scores, axis=1)
+ if not np.allclose(means_weighted, means_unweighted,
+ rtol=1e-4, atol=1e-4):
+ warn = True
+ break
+
+ if warn:
warnings.warn("The default of the `iid` parameter will change "
"from True to False in version 0.22 and will be"
" removed in 0.24. This will change numeric"
