skLearn2pmml带有pycaret模型到pmml的错误:对象不是superStimator的实例
到目前为止,使用Pycaret创建模型(训练了许多不同的型号),但是当使用Catboost时,我无法保存到PMML。该代码与XGBoost和LightGBM一起使用相同的数据。
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该为CATBOST模型使用特定的导出方法:
You should use specific export method for the catbost model:
请参阅jpmml-sklearn/sklearn2pmml堆栈支持的第三方套件的列表 -
从Sklearln2pmml 0.84(.2)中,lightgbm和Xgboost软件包在支持下列出,而Catboost套件则没有。
CATBOOST具有内置的PMML转换器(请参阅“ 应用PMML ”)。尝试将其集成到您的工作流程中。
See the list of 3rd party packages that are supported by the JPMML-SkLearn/SkLearn2PMML stack - https://github.com/jpmml/jpmml-sklearn#supported-packages
As of SkLearn2PMML 0.84(.2), the LightGBM and XGBoost packages are listed as supported, whereas the CatBoost package isn't.
CatBoost has built-in PMML converter (see "apply pmml"). Try to integrate this into your workflow instead.