Custom Objectives

I’m working on writing my own custom objective for building trees with xgboost. I implemented a callable in python to calculate the gradient and Hessian and passed it into xgboost.train as the obj argument, however, what I noticed is that the objective parameter seems to still get used. If I pass objective=binary:logistic along with a custom obj the resulting trees would change from when I don’t. I could not find documentation on what it’s doing. Even when I use a simple custom obj version of binary:logistic with no objective parameter specified I get different trees. So, what is it doing when you set both obj and objective? Also, with a custom obj callable is it still applying regularization?

You should upgrade to the latest XGBoost, so that your custom objective will receive the raw (un-transformed) prediction. Prior to 1.1.0 release, the custom objective would receive the transformed prediction, which depended on objective parameter.

See the demos in and

Does this change apply to the latest R release as well?

Yes, it applies to the R package as well.