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


#1

Hi,
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?

Thanks
Philip


#2

Does creating DMatrix add a lot of overhead?


#3

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…


#4

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


#5

@thvasilo Thanks for the answer. Yes. That is exactly what I have done. And it needs a DMatrix as input. See here: https://xgboost.readthedocs.io/en/latest/python/python_api.html#xgboost.XGBRegressor.predict


#6

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.