python出错 unexpected keyword argument 'categories'

python 运行OneHotEncode出错:TypeError: init() got an unexpected keyword argument 'categories’
运行一个网上的GBDT+LR 开源代码 报下面的错:

Traceback (most recent call last):
  File "D:/code/test_ML/plot_feature_transformation.py", line 65, in <module>
    rf_enc = OneHotEncoder(categories='auto')
TypeError: __init__() got an unexpected keyword argument 'categories'

解决办法

经过实践可能是 scikit_learn 和 numpy版本过低
删除原有scilit_learn 安装0.21版(原来是0.19)
删除原有numpy 安装1.17(原来是1.14)
再运行调用 OneHotEncoder 的文件错误消失。

首先卸载scikit-learn

C:\Users\dd>pip uninstall scikit-learn
Uninstalling scikit-learn-0.19.1:
  Would remove:
    d:\programdata\anaconda3\lib\site-packages\scikit_learn-0.19.1-py3.6.egg-info
    d:\programdata\anaconda3\lib\site-packages\sklearn
Proceed (y/n)? y
  Successfully uninstalled scikit-learn-0.19.1

下载scikit-learn 新版

widows安装包下载链接
https://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn
linux安装包下载链接https://pypi.org/project/scikit-learn/#files

安装scikit-learn新版

windows系统下安装

D:
cd D:\download\install_src\PythonPacket
pip install scikit_learn-0.21.3-cp36-cp36m-win_amd64.wh

linux系统下安装

$ cd /mnt/hgfs/D/download/install_src/PythonPacket/
$pip install scikit_learn-0.21.3-cp36-cp36m-manylinux1_x86_64.whl

下载numpy 新版

widows安装包下载链接
https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
linux安装包下载链接https://pypi.org/project/numpy/#files

安装numpy新版

Windows系统下安装

D:\download\install_src\PythonPacket>pip install "numpy-1.17.2+mkl-cp36-cp36m-win_amd64.whl"
Processing d:\download\install_src\pythonpacket\numpy-1.17.2+mkl-cp36-cp36m-win_amd64.whl
distributed 1.21.8 requires msgpack, which is not installed.
Installing collected packages: numpy
Successfully installed numpy-1.17.2+mkl
You are using pip version 10.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

linux系统下安装

$ cd /mnt/hgfs/D/download/install_src/PythonPacket/
$pip install numpy-1.17.3-cp36-cp36m-manylinux1_x86_64.whl

Skit_learn 库的使用,可以参考相关文章1


  1. 链接 https://www.cnblogs.com/wj-1314/p/10179741.html ↩︎

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值