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
Currently, using OrdinalEncoder with a string-valued feature, and without categories explicitly specifying an order, means that OrdinalEncoder will number the categories according to their lexicographic ordering.
This is not appropriate if the categories have a natural ordering (e.g. ['Green', 'Amber', 'Red']) that can be harnessed by the downstream estimator.
Rather, we should allow the user to specify categories='arbitrary' or categories='lexicographic' or something to explicitly state that lexicographic ordering is okay. When the user specifies categories='auto' for a string-valued feature, OrdinalEncoder should raise a warning along the lines of DeprecationWarning("From version 0.24, OrdinalEncoder's categories='auto' setting will not work with string-valued features, and categories='arbitrary' or an explicit category order will be required.")
Yes, but there might be some dispute among core developers about what the
correct API looks like. If you give it a go and open a pull request, that
at least gives us something tangible to consider.
I think that #14984, #15050, and #15396 might not be blockers for 0.22 and I would move them for 0.23.
I think that it could be great to have a single issue (superseded #14953, #14954) to discuss the overall behaviour for categories in OneHotEncoder and OrdinalEncoder and from there having several PRs which follows the discussed proposals.
@glemaitre Hi, random suggestion but what the function has a parameter named mapping that takes in a dictionary with keys being strings or some type of data and values being integers (either in a float or int form)?
I propose to change the behavior of categories="auto" to use the available order of the dtype if available. But no warning because OrdinaleEncoder has important use cases for unordered categoricals, see #14953 (comment).
Activity
venkyyuvy commentedon Sep 12, 2019
Can I work on this?
jnothman commentedon Sep 12, 2019
Alexrand1 commentedon Sep 12, 2019
Can you point me to where the file is located in the repo?
PyExtreme commentedon Sep 22, 2019
Hi, @venkyyuvy , Are you still working on this? Since, I am also interested to contribute.
Thanks
venkyyuvy commentedon Sep 22, 2019
yes @PyExtreme
I had raised a PR already, waiting for reviews!
glemaitre commentedon Nov 15, 2019
I think that #14984, #15050, and #15396 might not be blockers for 0.22 and I would move them for 0.23.
I think that it could be great to have a single issue (superseded #14953, #14954) to discuss the overall behaviour for
categoriesinOneHotEncoderandOrdinalEncoderand from there having several PRs which follows the discussed proposals.Add fix to scikit-learn#14954
Add unit tests to the fix of scikit-learn#14954
yahoyoungho commentedon Jul 21, 2021
@glemaitre Hi, random suggestion but what the function has a parameter named
mappingthat takes in a dictionary with keys being strings or some type of data and values being integers (either in a float or int form)?lorentzenchr commentedon May 28, 2026
I propose to change the behavior of
categories="auto"to use the available order of the dtype if available. But no warning because OrdinaleEncoder has important use cases for unordered categoricals, see #14953 (comment).