changing cost function in xgboost
This is discussed in stackoverflow, just to recap: 

Define your your customized cost function, e.g.:

 def new_cost(y_pred, y_true):
    # perform calculation for new cost
    return 'new_cost', score


Then pass it to the feval argument (see official doc) for training like:

model = xgboost.train(params, dtrain, num_rounds, watchlist, feval=new_cost)


There are many examples out there if you search harder for more concrete use cases.