Python: Want to call XGBClassifier.predict just with data and not DMatrix


I want to call XGBClassifier.predict just with data and not with DMatrix.
This is because I want to use a trained XGBClassifier together with DESlib.
This is an ensemble learning library.
Because the API of DESlib is calling all predict functions just with data and not
with DMatrix I have a problem.

Is there any XGBClassifier that wraps predict in a way that uses just data and not DMatrix?



Does creating DMatrix add a lot of overhead?


It is not a question of overhead.

But since I use use the XGBClassifier in an ensemble and wrapper together with other Sklearn Classifier it is not possible to pass a DMatrix to XGBClassifier and the “normal data” to the others.

But I could just write my own wrapper…


@PhilipMay have you looked at the sklearn wrapper for XGboost?


@thvasilo Thanks for the answer. Yes. That is exactly what I have done. And it needs a DMatrix as input. See here:


In that case using a wrapper might be the way to go. I think this question has come up before, you might want to search this forum for other solutions.