# XGBoost evaluation metric unbalanced data - custom eval metric

I have built a model using the xgboost package (in R), my data is unbalanced (5000 positives vs 95000 negatives), with a binary classification output (0,1).

I have performed cross validation with the evaluation metric AUC Area under the ROC curve which I now believe to be wrong since this is better used for balanced data sets.

I analyse the final results of the model using the Area Under the Precision Recal curve (AUPRC) and the Matthews Correlation Coefficient (MCC), however I now believe that I should have been evaluating the cross validation models with the AUPRC and MCC also and completely forget about the AUROC.

I cannot find much in the literature which uses CV with the evaluation metric of AUPRC and MCC.

I just want to make sure that I am thinking correctly and that my previous evaluation method is wrong and the AUPRC / MCC would be a better way to go.

• It is incorrect that AUC has any issue with class balance. AUC is insensitive to class balance, being the probability that the model scores a positively labeled class higher than a negatively labeled class. You should also consider evaluating model performance with log-loss, which, being based on probabilities, is also insensitive to class balance issues. It's important to seperate evaluating your model from evaluating your decision rule, these are different concerns. Jun 14, 2018 at 21:09
• This all depends on your application. What are you building the model for? Are you trying to build a decision rule, that needs to assign classes to new data points, or are the predicted probabilities sufficient for your purposes? Are you more interested in ranking? By evaluating your model with AUC, you are essentially saying that your dominant concern is how well your model ranks the data. The answers to these types of questions governs how you should evaluate your model. If you don't know, a very good default is log loss, since this ensures that your probabilities are accurate. Jun 14, 2018 at 21:17
• If the predicted probabilities are sufficient, then you're not building a decision rule, so there is no concept of type one error. If you'd like to ensure that the predicted probabilities are well calibrated to your data, then evaluating and comparing competing models on the basis of log loss is the way to go. You may also want to stratify your data when evaluating to make sure that your model is not just predicting well on some class off applicants (i.e. a model that does well on adults, but is crap on college students). Jun 14, 2018 at 21:32
• Note that by drawing something like a PR curve, you're drawing out how the model would preform as a decision rule over an entire range of thresholds. If you have no intention to set a threshold and use the model as a decision rule, than these kinds of evaluations are inappropriate for the application. Jun 14, 2018 at 21:33
• Please, please, please don't use 0.5 as a default threshold. This is almost always wrong. If you intend to do this, you NEED to tune the threshold of your model based on your business objectives. The correct way to do this is to estimate the costs to your business of false positives and false negatives, and then use those to set a correct classification threshold. There is really no justification for using 0.5 as a default threshold in practice. Jun 14, 2018 at 21:40