【问题标题】:I keep getting a TypeError when using gbt_regression_prediction().compute with XGBoost and daal4py将 gbt_regression_prediction().compute 与 XGBoost 和 daal4py 一起使用时,我不断收到 TypeError
【发布时间】:2022-11-02 01:48:59
【问题描述】:

我有一个预训练的 XGBoost 模型,我想使用 daal4py 进行优化,但出现以下错误

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

这是引发错误的那一行:

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

【问题讨论】:

    标签: xgboost intel-oneapi intel-ai-analytics


    【解决方案1】:

    如果您将 XGBoost 对象传递给 d4p.gbt_regression_prediction().compute(x_test, xgb_model).prediction.reshape(-1),您将继续收到此错误。

    您必须先将模型转换为 daal4py 格式,然后才能将其传递给预测方法。请看下面的例子。

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

    【讨论】:

      猜你喜欢
      • 2020-05-31
      • 1970-01-01
      • 2019-11-24
      • 1970-01-01
      • 2020-05-31
      • 2019-12-12
      • 2014-10-06
      • 2018-09-23
      • 2023-04-08
      相关资源
      最近更新 更多