You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Have handle_unknown="ignore" by default in OneHotEncoder #19286
I would propose to make handle_unknown="ignore" the default in OneHotEncoder.
That's what one would want in most cases in practice, I believe. Real datasets often have infrequent categories and so depending on the train/test split the test set is likely to have some infrequent categories. Also in production systems, better to have unknown categories ignored than have the system crashing because of it.
This might be blocked due to a suboptimal interaction with the drop option #18072, and I'm not sure how this would interact with a few other proposed improvements to OHE lately.
This might be blocked due to a suboptimal interaction with the drop option #18072, and I'm not sure how this would interact with a few other proposed improvements to OHE lately.
The following should solve some of the issues: #19041
Hm I thought we already had an issue open for this, because indeed within cross-validation this is a pain.... I have been wishing for this for a long time ;)
Now that #19041 is merged we might want to reconsider this option of changing the default.
Great! Should we go forward with this then since no one is against it?
Actually there is also #16018 that should be considered w.r.t. the handling of the default option.
Unfrequent categories is a bit more tricky to use as a default IMO, in particular on how to choose the threshold frequency for a category to be unfrequent (which can be problem dependent). Also if that parameter is not well chosen one can still end up with no unfrequent categories in train and some in tests.
Unfrequent categories is a bit more tricky to use as a default IMO, in particular on how to choose the threshold frequency for a category to be unfrequent (which can be problem dependent). Also if that parameter is not well chosen one can still end up with no unfrequent categories in train and some in tests.
That PR deprecates 'ignore' and converts it to 'auto', which behaves the same as 'ignore' until one specifies categories to be infrequent. (The reason for this is explained in the opening comment of #16018)
We have 'handle_unknown' warn that we are chagning the default to 'ignore' (in 1.2), merge ENH Adds infrequent categories to OneHotEncoder #16018 for 1.1, change the warning to say we are changing the default to 'ignore' in 1.2 and also warn that we are changing the default again to 'auto' in 1.3. (This is kind of awkward)
Activity
glemaitre commentedon Jan 27, 2021
The following should solve some of the issues: #19041
glemaitre commentedon Jan 27, 2021
It is true that we can encounter this case quite often so it could be good to shift the default.
amueller commentedon Feb 6, 2021
Hm I thought we already had an issue open for this, because indeed within cross-validation this is a pain.... I have been wishing for this for a long time ;)
ogrisel commentedon Apr 1, 2021
Now that #19041 is merged we might want to reconsider this option of changing the default.
ogrisel commentedon Apr 1, 2021
Actually there is also #16018 that should be considered w.r.t. the handling of the default option.
rth commentedon Apr 1, 2021
Great! Should we go forward with this then since no one is against it?
Unfrequent categories is a bit more tricky to use as a default IMO, in particular on how to choose the threshold frequency for a category to be unfrequent (which can be problem dependent). Also if that parameter is not well chosen one can still end up with no unfrequent categories in train and some in tests.
thomasjpfan commentedon Apr 1, 2021
That PR deprecates
'ignore'and converts it to'auto', which behaves the same as 'ignore' until one specifies categories to be infrequent. (The reason for this is explained in the opening comment of #16018)So there are three paths here:
handle_unknownwarn that we are changing the default to 'ignore' and actually change the default in 1.2handle_unknownwarn that we are changing the default to 'auto', and actually change the default in 1.2'handle_unknown' warn that we are chagning the default to 'ignore' (in 1.2), merge ENH Adds infrequent categories to OneHotEncoder #16018 for 1.1, change the warning to say we are changing the default to 'ignore' in 1.2 and also warn that we are changing the default again to 'auto' in 1.3. (This is kind of awkward)rth commentedon Apr 1, 2021
Thanks for the summary, I didn't click on the link and thought it was an earlier iteration of that PR.
Option 2 sounds good to me then.