基于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
说明:关于pip的安装,请参考博文:http://wutengfei.blog.51cto.com/10942117/1975003
-
安装安装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账户下操作一切正常,但我切换到普通账户时出现报错,如下:
解决方法:
[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即可!