-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] Add deprecation warning for iid in BaseSearchCV #9103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sorry, what is the connection between this and #9031? |
sklearn/grid_search.py
Outdated
@@ -398,6 +398,11 @@ def __init__(self, estimator, scoring=None, | |||
self.pre_dispatch = pre_dispatch | |||
self.error_score = error_score | |||
|
|||
if not self.iid: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iid should be set to None and if it's not none, the warning should be shown, and if it is None, it should behave as True
(as that's the current behavior)
Sorry about linking to the wrong issue, failed tab completion on my side. |
lol, I was hoping the corresponding issue would have some links to resources that I could use to authoritatively convince others why this kind of cv is wrong. Thanks though! |
lol, I was hoping the corresponding issue would have some links to resources
that I could use to authoritatively convince others why this kind of cv is
wrong. Thanks though!
The core issue is that "iid=True" does not compute what cross-validation
strives to estimate (formula 3 of
https://academic.oup.com/gigascience/article/doi/10.1093/gigascience/gix020/3073663/Using-and-understanding-cross-validation
)
Yes, it's complicated, but that what it really boils down to.
|
This is a great writeup, thanks @GaelVaroquaux! |
e513b8f
to
451811b
Compare
451811b
to
7ad4b06
Compare
..deprecated:: 0.19 | ||
Parameter ``iid`` has been deprecated in version 0.19 and | ||
will be removed in 0.21. | ||
Future (and default) behavior is equivalent to `iid=true`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But isn't @GaelVaroquaux saying that this behaviour is inappropriate? #9103 (comment)
Rather we should be both deprecating the parameter and changing the default.
Needs a merge with master |
Ok this is really bad. We want this to be This will likely raise a warning for everybody using GridSearchCV. |
Actually, we should detect whether score is accuracy or the score method of ClassifierMixin and not raise a warning in that case. |
Hmm questions is whether we will special case the pipeline score to avoid warning in that case if possible. |
wait, I thought the iid was doing something different from what it was doing. It's just doing a weighted mean instead of a non-weighted mean? So that is independent of what metric we are using.... and we need to warn whenever the sample numbers are not the same? |
hm... not sure that is actually a blocker... I thought it would to actually equal treatment of all data points, but it doesn't really. |
for me one option is the same as cross_val_score(...).mean() and the other
is metric(y, cross_val_predict(X, y, ...))
|
well iid does neither of those, just weights the average.
…On 17 Jul 2017 5:19 am, "Alexandre Gramfort" ***@***.***> wrote:
for me one option is the same as cross_val_score(...).mean() and the other
is metric(y, cross_val_predict(X, y, ...))
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9103 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz64phydqgvb25lis0-nKMhrU0OjUAks5sOmJGgaJpZM4N2JFL>
.
|
ok. Yeah let's remove this weird option.
|
+1 for deprecating the In practice, it's very unlikely to significantly change the outcome of a grid search as most of our CV strategies will yield CV-folds with approximately equal sizes. The impact will probably be at noise level. |
The default can be changed immediately, but not without warning. The change
may be noise, but it should be explicable for users
…On 17 Jul 2017 6:59 pm, "Olivier Grisel" ***@***.***> wrote:
+1 for deprecating iid and changing the default behavior (to do the
equivalent of iid=False) right away without a FutureWarning but with
proper documentation in the whats_new.rst.
I practice, it's very unlikely to significantly change the outcome of a
grid search as most of our CV strategies will yield CV-folds with
approximately equal sizes. The impact will probably be at noise level.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9103 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz64LE4ppdZe-ZMlbwDx0rEAK-TX_Xks5sOyKNgaJpZM4N2JFL>
.
|
I am afraid that the |
that's a fair point.
|
I would like to note that any group-based splitter could well have very
imbalanced test set sizes and users would get very different scores and
best estimators if the default changed... But such cases should not, in
theory, have used iid=True.
…On 17 Jul 2017 8:19 pm, "Joel Nothman" ***@***.***> wrote:
that's a fair point.
On 17 Jul 2017 7:52 pm, "Olivier Grisel" ***@***.***> wrote:
I am afraid that the FutureWarning is going to be very annoying. It
cannot be silenced off by passing iid=False explicitly because this would
trigger a DeprecationWarning and we don't want to encourage our users to
explicit use the iid parameter in their code.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9103 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz67yLb7JIsq07F51Z8ewVes9U_R1qks5sOy7ngaJpZM4N2JFL>
.
|
So we don't really have a consensus, right? 1- warn to change in two versions (my PR: #9379). Noisy but can be silenced but takes 4 releases to go away. When I created my PR I thought the change was much more significant. I agree that it will be very small in most cases. It's hard to warn selectively as even KFold and StratifiedKFold can create these warnings. One option would be to only warn for splitters where the folds have very uneven sizes, so the grouped ones, the TimeSeriesSplit and any custom ones. |
@GaelVaroquaux what's your opinion? |
similarly to warning only if it's an imbalanced cv strategy, we could warn
if the weighted and unweighted means differ greatly, but "greatly" is
metric-dependent.
I don't really see that we lose anything with the current (slow) approach.
It maximises awareness of the change and minimises incompatibilities.
On 19 Jul 2017 3:15 am, "Olivier Grisel" <notifications@github.com> wrote:
@GaelVaroquaux <https://github.com/gaelvaroquaux> what's your opinion?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9103 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz67YaLV4KcbuwIhGxbbfopdEllM0rks5sPOg0gaJpZM4N2JFL>
.
|
It would be good to get input from @GaelVaroquaux before releasing |
Reference Issue
#9085
What does this implement/fix? Explain your changes.
Deprecate iid param.
Any other comments?