I'm using XGBoost for a binary classification problem. There is no negative label, only 1 and 0.

I tunned the hyperparameters using Bayesian optimization then tried to train the final model with the optimized hyperparameters.

Mdl_XGB = xgb.train(OptimizedParams, dtrain)

scores_train = Mdl_XGB.predict(dtrain)

scores_test = Mdl_XGB.predict(dtest)

My problem is that the predicted scores for both train and test sets include both negative values and numbers greater than one. The scores are between -0.23 and 1.13.

Shouldn't these scores present the probability of belonging to class 1 (positive class)?

  • 1
    $\begingroup$ Can you include the code for model creation and the outputs? As a side note: the word "scores" might be confusing here since it is usually used for performance scores like accuracy. It is more common to write pred_train = Mdl_XGB.predict(dtrain). $\endgroup$
    – Jonathan
    Mar 4, 2020 at 16:49

1 Answer 1


You have to set the option objective = binary:logistic to get probabilities between 0 and 1, otherwise you only get relative scores.

  • 1
    $\begingroup$ Honestly: no. You shouldn't train a model without looking at the learning options. $\endgroup$ Mar 4, 2020 at 16:55
  • $\begingroup$ I guess I gave you the answer anyway. $\endgroup$ Mar 4, 2020 at 16:55
  • $\begingroup$ Added to the dictionary of optimized parameters. It worked. Thanks! $\endgroup$ Mar 4, 2020 at 17:19
  • $\begingroup$ I think it's worse than just "otherwise you only get relative scores". With the defaults, you are performing regression, with mse loss! $\endgroup$
    – Ben Reiniger
    Mar 4, 2020 at 19:49
  • $\begingroup$ You are right. But couldn’t you use the output of such regression as a « score » ? $\endgroup$ Mar 4, 2020 at 21:10

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.