Python XGBRegressor: dressing a booster without fit

when fitting a XGBRegressor, a Booster object can be passed via the model parameter. Before fitting a XGBRegressor, the predict method does not work, which makes sense. The Booster Object has a predict method that works well (you have to convert the features to a DMatrix, though).

I want to dress a Booster object to a XGBRegressor so that before fitting the predict method of the XGBRegressor works, using the one from the Booster and accepting non DMatrix features. In Code

booster = Booster().load_model('path_to_save')
model = XGBRegressor(parameters)
model.set_booster(booster) # <== that is the line I am looking to achieve
model.predict(X) # so that this then works

Thank you very much!

Booster and XGBRegressor are different types of objects, it’s possible to use them together for regression. But for classification, you might run into issues.

But non the less, try this:

model = XGBRegressor(**parameters)

Thank you very much!
I did not know that the model you pass to the sklearn.load_model interface is a booster!
The docs are rather vague about it

load_model( fname )
Load the model from a file or bytearray. Path to file can be local or as an URI.
The model is loaded from XGBoost format which is universal among the various XGBoost interfaces.