1. 程式人生 > >Linux 下安裝xgboost

Linux 下安裝xgboost


0) 安裝Git:
sudo apt-get install git


1) 從Github下載最新原始碼:
git clone --recursive https://github.com/dmlc/xgboost


2) build:
cd xgboost
make -j4
如果是新機器,發現g++ not found錯誤:sudo apt-get install g++,再make。


3) 安裝python包
sudo apt-get install python-setuptools
cd python-package
sudo python setup.py install


4) 測試安裝結果

import xgboost
xgboost.__version__  # '0.6'


5) Demo
import xgboost as  xgb

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':0,'objective':'binary:logistic'}

num_round=100

bst=xgb.train(param,dtrain,num_round)

# make prediction

preds=bst.predict(dtest)