0
$\begingroup$

I'm using XGBoost on a dataset with 3 classes. However, I primarily care about the precision of 2 of the classes. It should also have decent recall, otherwise the algorithm might classify everything as the 3rd class.

How would I write a custom objective function for this? I'm not too familiar with gradients and Hessian.

$\endgroup$
1
  • 1
    $\begingroup$ Xgboost does not make class assignments, it estimates class membership probabilities. The class assignments are a seperate issue from the training of a predictive model. You should fit the model to minimize log-loss (aka cross entropy aka deviance), as usual, and then tune class assignments from the predicted probabilities to meet your problem goals. There's no reason to change the way xgboost works to solve a problem like this. $\endgroup$ Commented Dec 12, 2017 at 1:02

1 Answer 1

0
$\begingroup$

It might not be what you are looking for, but by your description is sounds like there is an imbalance towards the third class in the data set. In which case you could assign different weights to each class: https://github.com/dmlc/xgboost/blob/master/demo/kaggle-higgs/higgs-train.R#L17.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.