基于linux6.x安装xgboost

基于linux6.x安装xgboost


  1. 系统信息

    [root@ceshiji ~]# cat /etc/redhat-release 

    CentOS release 6.5 (Final)

  2. python信息

    [root@ceshiji ~]# python --version

    Python 2.7.3

  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

  4. 安装pip

    说明:关于pip的安装,请参考博文:http://wutengfei.blog.51cto.com/10942117/1975003

  5. 安装安装sk-learn  

    [root@ceshiji ~]# pip install -U scikit-learn==0.16.0

  6. 下载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/

  7. 编译

    [root@ceshiji xgboost-0.47]#  make -j4

  8. 安装Python模块,使用anaconda的Python

    [root@ceshiji xgboost-0.47]# cd python-package/

    [root@ceshiji python-package]# python setup.py install

    这时系统会有报错,如下:

    c78454a3d5da331cacf4c6ba201988d6.png

    解决方法:

    [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

  9. 将xgboost导入python中

    [root@ceshiji ~]# python

    >>> import xgboost

    >>> 

    说明:上面标明xgboost已经成功导入python中,我在root账户下操作一切正常,但我切换到普通账户时出现报错,如下:

    f20ec8da497816f4f92f314d35341fba.jpg

    解决方法:

    [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,如需转载请自行联系原作者






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值