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 的文件错误消失。
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
widows安装包下载链接
https://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn
linux安装包下载链接https://pypi.org/project/scikit-learn/#files
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
widows安装包下载链接
https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
linux安装包下载链接https://pypi.org/project/numpy/#files
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
链接 https://www.cnblogs.com/wj-1314/p/10179741.html ↩︎