基于linux6.x安装xgboost
  TEZNKK3IfmPf 2023年11月14日 24 0

基于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

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

    基于linux6.x安装xgboost

  9. 解决方法:

    [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

  10. 将xgboost导入python中

    [root@ceshiji ~]# python

    >>> import xgboost

    >>> 

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

    基于linux6.x安装xgboost

    解决方法:

    [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即可!

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月14日 0

暂无评论

TEZNKK3IfmPf