基于linux6.x安裝xgboost
系統資訊
[root@ceshiji ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
python資訊
[root@ceshiji ~]# python --version
Python 2.7.3
安裝基礎插件(安裝 anaconda)
[root@ceshiji ~]# yum install gcc gcc-c++
[root@ceshiji ~]# yum install lapack lapack-devel blas blas-devel
[root@ceshiji ~]# yum install scipy numpy
安裝pip
安裝安裝sk-learn
[root@ceshiji ~]# pip install -U scikit-learn==0.16.0
下載下傳xgboost 的源碼,解壓
[root@ceshiji ~]# wget https://github.com/dmlc/xgboost/archive/0.47.tar.gz
[root@ceshiji ~]# tar -zxvf 0.47.tar.gz
[root@ceshiji ~]# cd xgboost-0.47/
編譯
[root@ceshiji xgboost-0.47]# make -j4
安裝Python子產品,使用anaconda的Python
[root@ceshiji xgboost-0.47]# cd python-package/
[root@ceshiji python-package]# python setup.py install
這時系統會有報錯,如下:
[root@ceshiji python-package]# vim setup.py
修改setup.py中
include_package_data=False, (原來是True)
再次運作python setup.py install 即可!
提示如下表示安裝成功:
Using /root/anaconda2/lib/python2.7/site-packages
Finished processing dependencies for xgboost==0.4
将xgboost導入python中
[root@ceshiji ~]# python
>>> import xgboost
>>>
說明:上面标明xgboost已經成功導入python中,我在root賬戶下操作一切正常,但我切換到普通賬戶時出現報錯,如下:
<a href="https://s4.51cto.com/oss/201711/06/f20ec8da497816f4f92f314d35341fba.jpg" target="_blank"></a>
解決方法:
[root@ceshiji ~]# cd xgboost-0.47/python-package/xgboost
[root@ceshiji xgboost]# cp __init__.py /usr/local/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/xgboost/
[root@ceshiji xgboost]# cp VERSION /usr/local/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/xgboost/
再次import xgboost即可!
本文轉自品鑒初心51CTO部落格,原文連結:http://blog.51cto.com/wutengfei/1979471,如需轉載請自行聯系原作者