本文介绍了Scikit Learn 预处理中的分类编码器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 sklearn 中导入分类编码器

I was trying to import Categorical Encoder in sklearn

from sklearn.preprocessing import CategoricalEncoder

但我收到错误

ImportError: cannot import name 'CategoricalEncoder' from 'sklearn.preprocessing' (D:\ProgramData\Miniconda3\lib\site-packages\sklearn\preprocessing\__init__.py)

我有 0.21.3 版的 sklearn.

I have version 0.21.3 of sklearn.

我在网上查看了文档,似乎 CategoricalEncoder 出现在 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)但在 0.21.3 (https://scikit-learn.org/stable/modules/classes.html#module-sklearn.preprocessing)

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)

CategoricalEncoder 怎么了?有没有办法我仍然可以使用它?就像我可以导入 2 个版本的 sklearn 并从 0.20.dev0 版本中提取它

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

推荐答案

CategoricalEncoder 仅在开发版本 0.20.dev0 中可用.使用 OneHotEncoderOrdinalEncoder 已安装.(参见 #10521)

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

这篇关于Scikit Learn 预处理中的分类编码器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 19:06