Python XGBoost prediction discrepancies with DMatrix

Viewed 106

I found there are 2 problems with xbgoost predictions. I trained the model with XGBClassifier and tried to load the model using Booster for prediction, I found

  1. Predictions are slightly different using xbg.Booster and xgb.Classifier, see below.

enter image description here

  1. Predictions are different between list and numpy array when using DMatrix, see below,

enter image description here

Some difference is quite big, I am not sure why this is happening and which prediction should be the source of truth?

1 Answers

For the second question, your data types could change when you convert a list to a numpy array (depending on the numpy version you're using). For example on numpy 1.19.5, try converting list ["1",1] to a numpy array and see the result.

Related