make wrapper ok

This commit is contained in:
tqchen
2014-11-23 14:03:59 -08:00
parent 69b2f31098
commit 5f08313cb2
15 changed files with 160 additions and 24 deletions

View File

@@ -1,6 +1,11 @@
Distributed XGBoost: Column Split Version
====
* run ```bash mushroom-row.sh <n-mpi-process>```
* run ```bash mushroom-col.sh <n-mpi-process>```
* run ```bash mushroom-col-tcp.sh <n-process>```
- mushroom-col-tcp.sh starts xgboost job using xgboost's buildin allreduce
* run ```bash mushroom-col-python.sh <n-process>```
- mushroom-col-python.sh starts xgboost python job using xgboost's buildin all reduce
- see mushroom-col.py
How to Use
====

View File

@@ -0,0 +1,22 @@
#!/bin/bash
if [[ $# -ne 1 ]]
then
echo "Usage: nprocess"
exit -1
fi
#
# This script is same as mushroom-col except that we will be using xgboost python module
#
# xgboost used built in tcp-based allreduce module, and can be run on more enviroment, so long as we know how to start job by modifying ../submit_job_tcp.py
#
rm -rf train.col* *.model
k=$1
# split the lib svm file into k subfiles
python splitsvm.py ../../demo/data/agaricus.txt.train train $k
# run xgboost mpi
../submit_job_tcp.py $k python mushroom-col.py
cat dump.nice.$k.txt

View File

@@ -0,0 +1,29 @@
import os
import sys
sys.path.append(os.path.dirname(__file__)+'/../wrapper')
import xgboost as xgb
# this is example script of running distributed xgboost using python
# call this additional function to intialize the xgboost sync module
# in distributed mode
xgb.sync_init(sys.argv)
rank = xgb.sync_get_rank()
# read in dataset
dtrain = xgb.DMatrix('train.col%d' % rank)
param = {'max_depth':3, 'eta':1, 'silent':1, 'objective':'binary:logistic' }
param['dsplit'] = 'col'
nround = 3
if rank == 0:
dtest = xgb.DMatrix('../../demo/data/agaricus.txt.test')
model = xgb.train(param, dtrain, nround, [(dtrain, 'train') , (dtest, 'test')])
else:
# if it is a slave node, do not run evaluation
model = xgb.train(param, dtrain, nround)
if rank == 0:
model.save_model('%04d.model' % nround)
# dump model with feature map
model.dump_model('dump.nice.%d.txt' % xgb.sync_get_world_size(),'../../demo/data/featmap.txt')
# shutdown the synchronization module
xgb.sync_finalize()