您的位置:首页 > 其它

xgboost在windows下的安装与使用

2016-07-25 09:44 591 查看
XGBoost wins many data science and machine learning challenges. Used in production by multiple companies.

下载:

使用Git Bash

git clone --recursive https://github.com/dmlc/xgboost[/code] 
上面下载的是xgboost的最新版本,还不支持windows,截至到(16年7月25日)。

我们需要手动下载它的0.4x版本,xgboost-0.47

安装

它的安装步骤主要分为两步:

首先打开xgboost-0.47源文件夹里的windows文件夹。使用 VS 打开xgboost.sln 工程。build the three shared library。我用的是2015社区版。





官方说明是需要使用x64,release,可以根据自己实际做选择,X32的操作步骤也一样。





这时生成了
xgboost.exe
for CLI and
xgboost_wrapper.dll
for python

然后在
cmd
里将路径改到xgboost文件夹里python-package目录
cd C:\Users\Administrator\xgboost-0.47
(根据自己的路径填写),在目录下执行
python setup.py install
。安装至此完成。

xgboost将会安装在你的python的Lib目录下,我用的Anaconda,所以在Anaconda下:



测试

在ipython里导入xgboost
import xgboost as xgb




可以用
demo
目录下的例子熟悉xgboost的使用。

xgboost/demo/

import xgboost as xgb
# read in data
dtrain = xgb.DMatrix('demo/data/agaricus.txt.train')
dtest = xgb.DMatrix('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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  机器学习 XGBoost