首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sklearn2pmml错误与pmml :对象不是BaseEstimator的实例

sklearn2pmml错误与pmml :对象不是BaseEstimator的实例
EN

Stack Overflow用户
提问于 2022-06-30 14:19:26
回答 2查看 102关注 0票数 0

创建一个使用pycaret的模型,到目前为止没有问题(训练了一组不同的模型),但是当使用catboost时,我不能保存到pmml。同样的代码也适用于具有相同数据的xgboost和lightgbm。

代码语言:javascript
复制
from sklearn2pmml.pipeline import PMMLPipeline
from sklearn2pmml import sklearn2pmml,make_pmml_pipeline
from pycaret.regression import setup,tune_model,finalize_model,create_model
    

clf=setup(data=df,
          target='target_Var',
          train_size= 0.8,
          fold_shuffle = True,
          fold = 5,
          fold_strategy="groupkfold",
          fold_groups="id",
          html = False,
          silent = True,
          session_id = 1,
          n_jobs = -1)

    model = create_model('catboost')
    tuned_model = tune_model(model, fold=5)
    final_model = finalize_model(tuned_model)
    model_pipeline = make_pmml_pipeline(final_model)
    sklearn2pmml(model_pipeline_pm, model_path)
        
             12     tuned_model = tune_model(model, fold=5)
             13     final_model = finalize_model(tuned_model)
        ---> 14     model_pipeline = make_pmml_pipeline(final_model)
        
        
        
        ~\Anaconda3\envs\cloned2\lib\site-packages\sklearn2pmml\__init__.py in make_pmml_pipeline(obj, active_fields, target_fields)
            138 
            139     """
        --> 140         steps = _filter_steps(_get_steps(obj))
            141         pipeline = PMMLPipeline(steps)
            142         if active_fields is not None:
        
        ~\Anaconda3\envs\cloned2\lib\site-packages\sklearn2pmml\__init__.py in _get_steps(obj)
             97                 return [("estimator", obj)]
             98         else:
        ---> 99                 raise TypeError("The object is not an instance of {0}".format(BaseEstimator.__name__))
            100 
            101 def _filter(obj):
        
        TypeError: The object is not an instance of BaseEstimator
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-07-01 08:45:19

您应该对catbost模型使用特定的导出方法:

代码语言:javascript
复制
if model == 'catboost' :
        final_model.save_model(path,format="pmml")
票数 1
EN

Stack Overflow用户

发布于 2022-07-01 06:34:17

请参见JPMML/SkLearn2PMML堆栈- https://github.com/jpmml/jpmml-sklearn#supported-packages支持的第三方包列表。

在SkLearn2PMML 0.84(.2)中,LightGBM和XGBoost包被列为受支持的包,而CatBoost包则不受支持。

CatBoost内置了PMML转换器(参见"应用pmml")。尝试将其集成到您的工作流中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72817449

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档