![](/img/trans.png)
[英]sklearn2pmml error with pycaret model to pmml : The object is not an instance of BaseEstimator
[英]How to create pmml from sklearn model that can be import to python file with sklearn-pmml-model?
我想从scikit-learn模型创建PMML文件。 pmml文件将从其他python文件读取/导入。 但是结果给了我各种各样的错误
错误清单:
现在我很困惑是哪个产生了错误。 创建pmml文件(导出)或导入pmml文件时是? 还是其他任何可以解决我的问题的图书馆建议?
我已经尝试过许多库,例如sklearn2pmml,nyoka和scikit2pmml来创建PMML文件,但是结果是相同的。
对于导入pmml文件,我正在使用sklearn-pmml-model。
创建模型:
#create model and export pmml files
import pandas
iris_df = pandas.read_csv("/smart_apps/iris2.csv")
from sklearn.tree import DecisionTreeClassifier
from sklearn2pmml.pipeline import PMMLPipeline
pipeline = PMMLPipeline([("classifier", DecisionTreeClassifier())])
pipeline.fit(iris_df[iris_df.columns.difference(["species"])], iris_df["species"])
from sklearn2pmml import sklearn2pmml
sklearn2pmml(pipeline, "model4.pmml", with_repr = True)
#import pmml
from sklearn_pmml_model.tree import PMMLTreeClassifier
model = PMMLTreeClassifier(pmml='/home/zeppelin/model4.pmml')
预期结果:成功导入pmml文件
您可以使用PyPMML在Python中导入pmml文件,例如:
from pypmml import Model
model = Model.fromFile('/home/zeppelin/model4.pmml')
result = model.predict(iris_df)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.