xgboost在Windows下的安装

1、从此https://git-for-windows.github.io/网址下载Git,安装Git,一直点击下一步即可

2、转到要安装xgboost的路径,输入下列命令下载xgboost

git clone --recursive https://github.com/dmlc/xgboost

xgboost在Windows下的安装

3、进入xgboost目录,输入以下命令

$ cd xgboost  

$ git submodule init  

$ git submodule update

4、下载MinGW,下载网址https://sourceforge.net/projects/mingw-w64/files/latest/download,下载后,安装MinGW,将MinGW配置到环境变量中,右键计算机->高级环境变量->环境变量->path,再添加mingw-w64安装的bin路径,我的是

D:\Software\mingw-w64\mingw-w64\x86_64-4.9.2-posix-seh-rt_v3-rev1\mingw64\bin

xgboost在Windows下的安装

5、关闭Git Bash终端,再次打开,刚刚添加的路径变量就生效了,输入以下命令检查效果:

$ which mingw32-make

xgboost在Windows下的安装

6$ alias make='mingw32-make'

$ cd xgboost/进入到xgboost路径下

输入下列命令安装xgboost模块

$ cd dmlc-core

$ make -j4

xgboost在Windows下的安装

$ cd ../rabit

$ make lib/librabit_empty.a -j4

xgboost在Windows下的安装

$ cd ..

$ cp make/mingw64.mk config.mk

$ make -j4

xgboost在Windows下的安装

7、执行完成之后就可以在Anaconda中安装XGBoost的python模块了。在电脑的开始菜单中打开Anaconda Prompt,转到D:\Software\xgboost\xgboost\python-package路径下,输入如下命令

python setup.py install

xgboost模块进行安装,出现下列信息:

xgboost在Windows下的安装

8、配置xgboost的环境变量

import os
mingw_path = 'D:\\Software\\mingw-w64\\mingw-w64\\x86_64-4.9.2-posix-seh-rt_v3-rev1\\mingw64\\bin'
os.environ['PATH'] = mingw_path + ';' + os.environ['PATH']

9、用下面小程序来测试xgboost是否安装成功

import xgboost as xgb
print xgb.libpath

 xgboost在Windows下的安装

10参考网站:

http://xgboost.readthedocs.io/en/latest/build.html#building-on-windows

http://blog.****.net/leo_xu06/article/details/52300869