def new_cost(y_pred, y_true): # perform calculation for new cost return 'new_cost', score model = xgboost.train(params, dtrain, num_rounds, watchlist, feval=new_cost)