参考文档:
http://dnc1994.com/2016/03/installing-xgboost-on-windows/
https://stackoverflow.com/questions/43327020/xgboostlibrarynotfound-cannot-find-xgboost-library-in-the-candidate-path-did-y
一、安装步骤
1、编译
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
wget https://www.dropbox.com/s/y8myex4bnuzcp03/Makefile_win?dl=1
cp Makefile_win Makefile
cp make/mingw64.mk config.mk
mingw32-make
2、安装
cd python-package
python setup.py install
二、关键
1、Makefile_win采用第三方
wget不好使的情况下, 可以这儿下载:
https://www.dropbox.com/s/y8myex4bnuzcp03/Makefile_win?dl=0
2、采用gitbash,需要安装Git
3、--recursive参数
4、TDM-GCC下载安装
http://tdm-gcc.tdragon.net/download
三、遇到的问题
1、问题一
#python setup.py install
GBoostLibraryNotFound:Cannot find XGBoostLibraryin the candidate path, did you install compilers and run build.shin root path?
解决:
找到libxgboost.dll
拷贝到xgboost/pythonp-package/xgboost中
#mv libxgboost.dll xgboost.dll
2、问题二
#python setup.py install
error: no lapack/blas resources found
解决:
1> 配置path路径:
PATH=C:\Python27\Scripts
升级pip命令
# python -m pip install -U pip
2> 安装scipy
重启gitbash,不然依然无法识别pip命令
#pip install scipy
四、intelij idea运行测试样例
1、样例
import xgboost as xgb # read in data dtrain = xgb.DMatrix('D:\\test\\xgboost\\demo\\data\\agaricus.txt.train') dtest = xgb.DMatrix('D:\\test\\xgboost\\demo\\data\\agaricus.txt.test') # specify parameters via map param = {'max_depth':2, 'eta':1, 'silent':1, 'objective':'binary:logistic' } num_round = 2 bst = xgb.train(param, dtrain, num_round) # make prediction preds = bst.predict(dtest)
2、错误
WindowsError: [Error 193] %1 is not a valid Win32 application
解决:
3、重新安装依赖软件
numpy安装
#pip install numpy
scipy安装
#pip install scipy
xgboost安装:
liuxq@sh-liuxq MINGW64 /home/liuxq/xgboost/python-package (master)
$ python setup.py install