win7 anaconda2 安装xgboost

本文详细介绍了如何在Win7系统中,基于Anaconda2环境安装xgboost。首先安装Anaconda,接着安装Git for Windows和MINGW,然后通过Git Bash下载并编译xgboost源代码,最后安装xgboost的Python模块,并验证安装是否成功。
摘要由CSDN通过智能技术生成

本人用python做数据分析,经常用到pandas,调用sklearn,于是偷个了小懒,直接安装了anaconda,它集成了很多python的工具包,安装也简单。
最近了解了一下GBM(gradient boosting machine),下面博客是一位寒小阳老师根据某次kaggle大赛上使用GBM处理赛事的流程。
http://blog.csdn.net/han_xiaoyang/article/details/52663170

xgboost的安装

在anaconda中安装xgoost
需要安装
python软件(本文基于Anaconda,因为自带很多库,比较方便)
Git for Windows
MINGW

1.首先安装了anaconda
我安装的是py2.7对应的anaconda,
https://www.anaconda.com/download/#windows
2.安装git
下载地址:
https://git-for-windows.github.io/?cm_mc_uid=41208005060614719434058&cm_mc_sid_50200000=1472023539
安装路径选取指定路径
3.安装mingw
https://sourceforge.net/projects/mingw-w64/?source=typ_redirect

这里写图片描述

然后选择x86_64的architecture

这里写图片描述

我选择安装路径是D盘,具体 D:\Program Files (x86)\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0
然后将D:\Program Files (x86)\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0\mingw64\bin这个文件夹的路径添加到自己电脑的环境变量中去。计算机->属性->高级系统设置->
这里写图片描述

进入环境变量的系统变量,将如上的路径添加到path中,注意需要用分号隔开。

这里写图片描述

开始菜单里打开Git Bash,输入:which mingw32-make后显示如下:
这里写图片描述
则mingw安装成功。
然后输入命令 alias make=’mingw32-make’ ,表示给mingw32-make取了一个别名(方便后面安装xgboost,简化命令)
这里写图片描述

4.安装xgboost

(1)下载xgboost文件
开始菜单里打开Git Bash,首先新建一个文件夹xgboostCode用于存放代码和下载文件,然后在刚刚打开的Bash终端中输入下面命令,
定位目录F:\software\xgboost_setup
命令
cd f:software/xgboost_setup
然后用下面的命令从GitHub下载XGBoost
输入命令 git clone –recursive https://github.com/dmlc/xgboost

这里写图片描述
已经将xgboost从github下载到目录F:\software\xgboost_setup中。
这里写图片描述

cd xgboost
git submodule init
git submodule update

(2)安装xgboost
首先定位到xgboost的下载路径:F:\software\xgboost_setup\xgboost
命令: cd f:software/xgboost_setup/xgboost

然后分别输入如下7条命令

  1. $ cd dmlc-core
  2. $ make -j4
  3. $ cd ../rabit
  4. $ make lib/librabit_empty.a -j4
  5. $ cd ..
  6. $ cp make/mingw64.mk config.mk
  7. $ make -j4
    进入路径xgboost/python-package,安装XGBoost的python模块,
    进入路径命令:
    cd f: software/xgboost_setup/xgboost/python-package
    然后安装python模块:
    python setup.py install

这里写图片描述

在anaconda 中验证
import numpy as np
import xgboost as xgb
data = np.random.rand(5,10) # 5 entities, each contains 10 features
label = np.random.randint(2, size=5) # binary target
dtrain = xgb.DMatrix( data, label=label)

参考博客:
http://blog.csdn.net/leo_xu06/article/details/52300869
http://blog.csdn.net/ni_guang2010/article/details/53350034

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值