[Solved] Categorical Encoder in Scikit Learn Preprocessing

I was trying to import Categorical Encoder in sklearn

from sklearn.preprocessing import CategoricalEncoder

But I get the error

ImportError: cannot import name 'CategoricalEncoder' from 'sklearn.preprocessing' (D:ProgramDataMiniconda3libsite-packagessklearnpreprocessing__init__.py)

I have version 0.21.3 of sklearn.

I checked online to see the documentation and it seems that CategoricalEncoder was there in version 0.20.dev0 (https://15359-843222-gh.circle-artifacts.com/0/home/ubuntu/scikit-learn/doc/_build/html/stable/modules/generated/sklearn.preprocessing.CategoricalEncoder.html)
But is not there in 0.21.3 (https://scikit-learn.org/stable/modules/classes.html#module-sklearn.preprocessing)

What happened to CategoricalEncoder?
Is there a way I can still use it? Like can I import 2 versions of sklearn and pull it from the 0.20.dev0 version

Solution #1:

CategoricalEncoder is only available in the development version 0.20.dev0. Use OneHotEncoder and OrdinalEncoder insted.(see #10521)

Respondent: Amine Benatmane

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.