Using DMatrix and the row directly give different results

Viewed 12

I am getting the first row from my X_test Dataframe and making a prediction in xgb_model like below,

fv = numpy.array(X_test_df.iloc[0]).reshape((1,-1))
print(xgb_model.predict(fv))

However, when I convert X_test into a DMatrix object, and then I get the first row, it yields a different result.

dtest = xgb.DMatrix(data=X_test_df.values,
                     feature_names=X_test_df.columns)
predictions = model_xgb.predict(dtest)
predictions[0]

Why would these be different? Aren't they supposed to be the same?

0 Answers
Related