Alhpa Delta
Alhpa Delta

Reputation: 3660

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:\ProgramData\Miniconda3\lib\site-packages\sklearn\preprocessing\__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

Upvotes: 1

Views: 10268

Answers (2)

user22324691
user22324691

Reputation: 1

We can import categorical encoder library directly. For example:

import category_encoders as ce

[If category_encoders is not installed first we need to install it ]

pip install category_encoders

https://pypi.org/project/category-encoders/

Upvotes: 0

Amine Benatmane
Amine Benatmane

Reputation: 1261

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

Upvotes: 4

Related Questions