在windows 10环境下安装xgboost

来源:互联网 发布:windows xp sp3激活码 编辑:程序博客网 时间:2024/06/05 19:46

1、  安装MinGW64

MinGW64官网下载不稳定,总是失败。我采用其编译器集成包TDM-GCC-64。

TDM-GCC-64下载地址:http://tdm-gcc.tdragon.net/。

我选择的是:tdm64-gcc-5.1.0-2.exe,如果下载过慢,可以选择切换镜像:如东京。

下载完后,再安装即可。

复制一份\TDMGCC\bin\mingw32-make.exe ,将其名字更改为make.exe,置于同目录下。

或者,可以用其它集成环境,参考:https://www.zhihu.com/question/26201557

 

2、  安装Git

官网下载也是很慢,采用离线下载方式,下载git再安装。

下载地址:http://download.csdn.net/detail/u010035907/9815705

 

3、安装xgboost。

(1)下载xgboost并编译

首先,打开Git Shell,依次执行如下命令:

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

cd xgboost

git checkout 9a48a40

git submodule init

git submodule update

 

cp make/mingw64.mk config.mk

cp make/mingw64.mk dmlc-core/config.mk

 

cd rabit

make lib/librabit_empty.a -j4

 

cd ../dmlc-core

make -j4

 

cd ..

make -j4

注:若有警告,可以忽略。

(2)安装到python包 \xgboost\python-package

cd python-package

python setup.py install

(3)导入xgboost包

import xgboost as xgb

help(xgb)

(4)使用clone下来的文件xgboost\demo进行程序测试

cd ..

cd demo

cd guide-python

python basic_walkthrough.py

结果如下:

C:\Users\hhxsym\Desktop\xgb\xgboost\demo\guide-python>pythonbasic_walkthrough.py

D:\usr\Anaconda2\lib\site-packages\sklearn\cross_validation.py:44:DeprecationWarning: This module was deprecated in version 0.18 in favor of themodel_selection module into which all the refactored classes and functions aremoved. Also note that the interface of the new CV iterators are different fromthat of this module. This module will be removed in 0.20.

 "This module will be removed in 0.20.", DeprecationWarning)

[14:19:55] 6513x127 matrix with 143286entries loaded from ../data/agaricus.txt.train

[14:19:55] 1611x127 matrix with 35442entries loaded from ../data/agaricus.txt.test

[0]    eval-error:0.042831    train-error:0.046522

[1]    eval-error:0.021726    train-error:0.022263

error=0.021726

[14:19:55] 1611x127 matrix with 35442entries loaded from dtest.buffer

start running example of build DMatrix fromscipy.sparse CSR Matrix

[0]    eval-error:0.042831    train-error:0.046522

[1]    eval-error:0.021726    train-error:0.022263

start running example of build DMatrix fromscipy.sparse CSC Matrix

[0]    eval-error:0.042831    train-error:0.046522

[1]    eval-error:0.021726    train-error:0.022263

start running example of build DMatrix fromnumpy array

[0]    eval-error:0.042831    train-error:0.046522

[1]    eval-error:0.021726     train-error:0.022263

 

至此,xgboost安装及验证完毕。

 

参考资料:

1、https://www.zhihu.com/question/26201557

2、http://blog.csdn.net/bon_mot/article/details/51742869#0-tsina-1-68989-397232819ff9a47a7b7e80a40613cfe1

 

0 0
原创粉丝点击