Search code examples
xgboostintel-oneapiintel-ai-analytics

I keep getting a TypeError when using gbt_regression_prediction().compute with XGBoost and daal4py


I have a pre-trained XGBoost model that I want to optimize with daal4py but I'm getting the following error

TypeError: Argument 'model' has incorrect type (expected daal4py._daal4py.gbt_regression_model, got XGBRegressor)

Here is the line with that is throwing the error:

y_pred = d4p.gbt_regression_prediction().compute(x_test, xgb_model).prediction.reshape(-1)


Solution

  • If you pass the XGBoost object to d4p.gbt_regression_prediction().compute(x_test, xgb_model).prediction.reshape(-1) you will continue to get this error.

    You must first convert the model to daal4py format before passing it to the prediction method. Please see the example below.

    daal_model = d4p.get_gbt_model_from_xgboost(xgb_model.get_booster())
    daal_model).prediction.reshape(-1)