1. 先下载源码 git clone --recursive https://github.com/dmlc/xgboost
2. 下载完后的源码在xgoobst里面, 到xgboost下建立build资料夹
3. 进入build资料夹,开启power shell 输入
cmake .. -G"Visual Studio 15 2017 Win64" -DUSE_CUDA=ON
其中 -DUSE_CUDA=ON 是使用gpu加速,不一定需要
成功后会显示
-- Build files have been written to: D:/wks/wks_ml_xgboost/xgboost/build
完成后再build文件夹里就会有.sln的文件, 点击xgboost.sln 用vs打开
4. 打开后右键生成解决方案,这个要花点时间
生成成功后在xgboost的lib下会有xgboost.dll 和 xgboost.lib
已上传有需要的可以点击去下载资源取
5. 如果要用python调用, 进入xgboost的python-package,打开控制台输入
python .\setup.py install
成功后会显示把lib和dll拷贝到python(或anaconda)的lib
进入pycharm看
6. 再来就可以测试了
import xgboost as xgb
dtrain = xgb.DMatrix(r'D:\wks\wks_ml_xgboost\xgboost\demo\data\agaricus.txt.train')
dtest = xgb.DMatrix(r'D:\wks\wks_ml_xgboost\xgboost\demo\data\agaricus.txt.test')
param = {'max_depth': 2, 'eta': 1, 'objective': 'binary:logistic'}
num_round = 2
bst = xgb.train(param, dtrain, num_round)
preds = bst.predict(dtest)
print(preds)
完成