简体   繁体   中英

sklearn2pmml: error when trying to save PMMLPipeline

I'm trying to save a CatboostClassifier model through the package sklearn2pmml:

pipeline = PMMLPipeline([
    ("model", CatBoostClassifier(...))])

pipeline.fit(...)


sklearn2pmml(pipeline, "path\pmml_object.pmml") 

Unfortunately, this is the error that I get:

Standard output is empty
Standard error:
Exception in thread "main" java.lang.IllegalArgumentException: The transformer object (Python class catboost.core.CatBoostClassifier) is not a supported Transformer
    at org.jpmml.python.CastFunction.apply(CastFunction.java:47)
    at sklearn.pipeline.Pipeline$1.apply(Pipeline.java:108)
    at sklearn.pipeline.Pipeline$1.apply(Pipeline.java:95)
    at com.google.common.collect.Lists$TransformingRandomAccessList.get(Lists.java:638)
    at sklearn2pmml.pipeline.PMMLPipeline.getHead(PMMLPipeline.java:629)
    at sklearn2pmml.pipeline.PMMLPipeline.encodePMML(PMMLPipeline.java:198)
    at com.sklearn2pmml.Main.run(Main.java:84)
    at com.sklearn2pmml.Main.main(Main.java:62)
Caused by: java.lang.ClassCastException: Cannot cast net.razorvine.pickle.objects.ClassDict to sklearn.Transformer
    at java.lang.Class.cast(Unknown Source)
    at org.jpmml.python.CastFunction.apply(CastFunction.java:45)
    ... 7 more

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-37-4da18df9921b> in <module>
----> 1 sklearn2pmml(pipeline, "path\pmml_object.pmml")

~\Anaconda3\lib\site-packages\sklearn2pmml\__init__.py in sklearn2pmml(pipeline, pmml, user_classpath, with_repr, debug)
    257                                 print("Standard error is empty")
    258                 if retcode:
--> 259                         raise RuntimeError("The SkLearn2PMML application has failed. The Java executable should have printed more information about the failure into its standard output and/or standard error streams")
    260         finally:
    261                 if debug:

RuntimeError: The SkLearn2PMML application has failed. The Java executable should have printed more information about the failure into its standard output and/or standard error streams

I've tried to search on stack overflow, but I didn't manage to find this exact error.

try allocating 4gb memory using java_opts as follows-

sklearn2pmml(pipeline, "path\pmml_object.pmml",java_opts=["-Xms4096m", "-Xmx4096m"])

Try increasing the gbs if the memory error still persists. Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM