add interact mode

This commit is contained in:
tqchen
2014-05-03 23:24:22 -07:00
parent 6fd77cbb24
commit 2057dda560
4 changed files with 40 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ dtrain = xgb.DMatrix('agaricus.txt.train')
dtest = xgb.DMatrix('agaricus.txt.test')
# specify parameters via map, definition are same as c++ version
param = {'bst:max_depth':4, 'bst:eta':1, 'silent':1, 'loss_type':2 }
param = {'bst:max_depth':2, 'bst:eta':1, 'silent':1, 'loss_type':2 }
# specify validations set to watch performance
evallist = [(dtest,'eval'), (dtrain,'train')]
@@ -23,7 +23,15 @@ preds = bst.predict( dtest )
labels = dtest.get_label()
print 'error=%f' % ( sum(1 for i in xrange(len(preds)) if int(preds[i]>0.5)!=labels[i]) /float(len(preds)))
bst.save_model('0001.model')
# dump model
bst.dump_model('dump.raw.txt')
# dump model with feature map
bst.dump_model('dump.raw.txt','featmap.txt')
# beta: interact mode
bst.set_param('bst:interact:expand',4)
bst.update_interact( dtrain, 'update', 0)
bst.dump_model('dump.raw2.txt')
###
# build dmatrix in python iteratively