Minor changes to code style (#2805)
Some minor changes to code style in file 'boost_from_prediction.py'.
This commit is contained in:
parent
452063c32d
commit
c71b62d48d
@ -4,15 +4,15 @@ import xgboost as xgb
|
|||||||
|
|
||||||
dtrain = xgb.DMatrix('../data/agaricus.txt.train')
|
dtrain = xgb.DMatrix('../data/agaricus.txt.train')
|
||||||
dtest = xgb.DMatrix('../data/agaricus.txt.test')
|
dtest = xgb.DMatrix('../data/agaricus.txt.test')
|
||||||
watchlist = [(dtest,'eval'), (dtrain,'train')]
|
watchlist = [(dtest, 'eval'), (dtrain, 'train')]
|
||||||
###
|
###
|
||||||
# advanced: start from a initial base prediction
|
# advanced: start from a initial base prediction
|
||||||
#
|
#
|
||||||
print ('start running example to start from a initial prediction')
|
print ('start running example to start from a initial prediction')
|
||||||
# specify parameters via map, definition are same as c++ version
|
# specify parameters via map, definition are same as c++ version
|
||||||
param = {'max_depth':2, 'eta':1, 'silent':1, 'objective':'binary:logistic' }
|
param = {'max_depth':2, 'eta':1, 'silent':1, 'objective':'binary:logistic'}
|
||||||
# train xgboost for 1 round
|
# train xgboost for 1 round
|
||||||
bst = xgb.train( param, dtrain, 1, watchlist )
|
bst = xgb.train(param, dtrain, 1, watchlist)
|
||||||
# Note: we need the margin value instead of transformed prediction in set_base_margin
|
# Note: we need the margin value instead of transformed prediction in set_base_margin
|
||||||
# do predict with output_margin=True, will always give you margin values before logistic transformation
|
# do predict with output_margin=True, will always give you margin values before logistic transformation
|
||||||
ptrain = bst.predict(dtrain, output_margin=True)
|
ptrain = bst.predict(dtrain, output_margin=True)
|
||||||
@ -21,4 +21,4 @@ dtrain.set_base_margin(ptrain)
|
|||||||
dtest.set_base_margin(ptest)
|
dtest.set_base_margin(ptest)
|
||||||
|
|
||||||
print ('this is result of running from initial prediction')
|
print ('this is result of running from initial prediction')
|
||||||
bst = xgb.train( param, dtrain, 1, watchlist )
|
bst = xgb.train(param, dtrain, 1, watchlist)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user