0

I have an XGBoost model trained using the Scikit XGBoostRegressor API. It is a binary classification problem. Now, I want to convert it to daal format for faster inference but I keep getting RuntimeError: Could not convert Python object to oneDAL table.

Here is my code

with open(r'xgboost-model', 'rb') as input_file:
    model = pickle.load(input_file)

import daal4py as d4p
daal_model = d4p.get_gbt_model_from_xgboost(model.get_booster()) 

predict = d4p.gbt_classification_prediction(2).compute(test2, daal_model).prediction

and I get..

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In [13], line 1
----> 1 prediction = d4p.gbt_classification_prediction(2).compute(test2, daal_model).prediction

File build/daal4py_cy.pyx:12628, in daal4py._daal4py.gbt_classification_prediction.compute()

File build/daal4py_cy.pyx:246, in daal4py._daal4py._execute_with_context.exec_func()

File build/daal4py_cy.pyx:12611, in daal4py._daal4py.gbt_classification_prediction._compute()

RuntimeError: Could not convert Python object to oneDAL table.
  • 1
    We have tried predicting from a Converted XGboost Model to Daal4py and it is working fine. We used Intel DevCloud for oneAPI JupyteLab for trying the workload. Could you please try the workload in DevCloud for oneAPI and check whether you are able to run without any error? Can you please provide "minimal reproducible" (example: stackoverflow.com/help/minimal-reproducible-example) so that we can try reproducing your issue from our end? – Athira - Intel Jan 09 '23 at 05:20

1 Answers1

0

Suggest to try current version - 2023.2.1 at least - it does contain API changes to simplify it and align with XGBoost API.

import daal4py as d4p
d4p_model = d4p.mb.convert_model(xgb_model)
d4p_prediction = d4p_model.predict(test_data)

https://intelpython.github.io/daal4py/model-builders.html