HB_ML_Challenge/xgboostR/wrapper/xgboost.py
def train(params, dtrain, num_boost_round = 10, evals = [], obj=None, feval=None):
    """ train a booster with given paramaters """
    bst = Booster(params, [dtrain]+[ d[0] for d in evals ] )
    if obj == None:
        for i in range(num_boost_round):
            bst.update( dtrain, i )
            if len(evals) != 0:
                sys.stderr.write(evaluate(bst, evals, i, feval)+'\n')
    else:
        # try customized objective function
        for i in range(num_boost_round):
            pred = bst.predict( dtrain )
            grad, hess = obj( pred, dtrain )
            bst.boost( dtrain, grad, hess )
            if len(evals) != 0:
                sys.stderr.write(evaluate(bst, evals, i, feval)+'\n')
    return bst
 train a booster with given paramaters 
train a booster with given paramaters
train a booster with given paramaters
def train(params, dtrain, num_boost_round = 10, evals = [], obj=None, feval=None):
    bst = Booster(params, [dtrain]+[ d[0] for d in evals ] )
    if obj == None:
        for i in range(num_boost_round):
            bst.update( dtrain, i )
            if len(evals) != 0:
                sys.stderr.write(evaluate(bst, evals, i, feval)+'\n')
    else:
        for i in range(num_boost_round):
            pred = bst.predict( dtrain )
            grad, hess = obj( pred, dtrain )
            bst.boost( dtrain, grad, hess )
            if len(evals) != 0:
                sys.stderr.write(evaluate(bst, evals, i, feval)+'\n')
    return bst
def train ( params , dtrain , num_boost_round = 10 , evals = [ ] , obj = None , feval = None ) : bst = Booster ( params , [ dtrain ] + [ d [ 0 ] for d in evals ] ) if obj == None : for i in range ( num_boost_round ) : bst . update ( dtrain , i ) if len ( evals ) != 0 : sys . stderr . write ( evaluate ( bst , evals , i , feval ) + '\n' ) else : for i in range ( num_boost_round ) : pred = bst . predict ( dtrain ) grad , hess = obj ( pred , dtrain ) bst . boost ( dtrain , grad , hess ) if len ( evals ) != 0 : sys . stderr . write ( evaluate ( bst , evals , i , feval ) + '\n' ) return bst
train a booster with given paramaters
train a booster with given paramaters
""" train a booster with given paramaters """ # try customized objective function
params
dtrain
num_boost_round
evals
obj
feval