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)
完成