【问题标题】:BentoML - Seving a CatBoostClassifier with cat_featuresBentoML - 使用 cat_features 提供 CatBoostClassifier
【发布时间】:2023-02-17 19:46:57
【问题描述】:

我正在尝试为使用列作为分类特征训练的 CatBoostClassifier 模型创建 BentoML 服务。如果我保存模型并尝试使用保存的模型(不是作为 BentoML 服务)进行一些预测,一切都会按预期进行,但是当我使用 BentML 创建服务时,我会收到错误消息

_catboost.CatBoostError:num_feature[non_default_doc_idx=0,feature_idx=2]="Tertiary" 的错误值:无法将 'b'Tertiary'' 转换为浮点数

该值位于名为“road_type”的列中,模型使用“object”作为该列的数据类型进行训练。

如果我尝试为“road_type”列提供浮点数或整数,则会出现以下错误

_catboost.CatBoostError: catboost/libs/data/model_dataset_compatibility.cpp:53: Feature road_type 在模型中是分类的,但在数据集中标记为不同

如果有人遇到同样的问题并找到解决方案,我将不胜感激。谢谢!

我尝试了不同的方法来保存模型或加载模型,但不幸的是它没有用。

【问题讨论】:

    标签: catboost bentoml


    【解决方案1】:

    您可以尝试将 cat_features 显式传递给 bentoml runner。 它会是这样的:

    from catboost import Pool
    
    runner = bentoml.catboost.get("bentoml_catboost_model:latest").to_runner()
    
    cat_features = [2] # specify your cat_features indexes
    prediction = runner.predict.run(Pool(input_data, cat_features=cat_features))
    

    【讨论】:

      猜你喜欢
      • 2019-12-25
      • 2023-04-09
      • 2021-07-28
      • 2020-09-09
      • 2012-02-22
      • 2021-07-30
      • 2019-08-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多