我有一个随机森林模型,我试图转换为pmml。我可以正确地适应模型,因为它不会抛出任何错误:
test_pipeline = PMMLPipeline([("rforest", RandomForestClassifier())])
test_pipeline.fit(trainX, trainY)
CPU times: user 1.18 s, sys: 61.6 ms, total: 1.24 s
Wall time: 1.25 s
但是当我尝试调用sklearn2pmml方法时出现错误:
sklearn2pmml(test_pipeline, "DecisionTreeIris.pmml", with_repr = True)
错误:
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
<ipython-input-38-9f07cfed11da> in <module>()
----> 1 sklearn2pmml(test_pipeline, "DecisionTreeIris.pmml", with_repr = True)
/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/__init__.pyc in sklearn2pmml(pipeline, pmml, user_classpath, with_repr, debug)
89 if(debug):
90 print(" ".join(cmd))
---> 91 subprocess.check_call(cmd)
92 finally:
93 if(debug):
/Users/dileeppatchigolla/anaconda/lib/python2.7/subprocess.pyc in check_call(*popenargs, **kwargs)
539 if cmd is None:
540 cmd = popenargs[0]
--> 541 raise CalledProcessError(retcode, cmd)
542 return 0
543
CalledProcessError: Command '['java', '-cp', '/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/guava-19.0.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/istack-commons-runtime-2.21.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/jaxb-core-2.2.11.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/jaxb-runtime-2.2.11.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/jcommander-1.48.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/jpmml-converter-1.2.0.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/jpmml-lightgbm-1.0.0.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/jpmml-sklearn-1.2.3.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/jpmml-xgboost-1.1.4.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/pmml-agent-1.3.4.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/pmml-model-1.3.4.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/pmml-model-metro-1.3.4.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/pmml-schema-1.3.4.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/pyrolite-4.15.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/serpent-1.16.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/slf4j-api-1.7.22.jar:/Users/dileeppatchigolla/.local/lib/python2.7/site-packages/sklearn2pmml/resources/slf4j-jdk14-1.7.22.jar', 'org.jpmml.sklearn.Main', '--pkl-pipeline-input', '/var/folders/1j/5zzgmlk16ql5mm9z6_3n0c840000gp/T/pipeline-G164OK.pkl.z', '--repr-pipeline', "PMMLPipeline(steps=[('rforest', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',\n max_depth=None, max_features='auto', max_leaf_nodes=None,\n min_samples_leaf=1, min_samples_split=2,\n min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,\n oob_score=False, random_state=None, verbose=0,\n warm_start=False))])", '--pmml-output', 'DecisionTreeIris.pmml']' returned non-zero exit status 1
有人可以帮我调试错误日志并提供解决方案吗?
答案 0 :(得分:0)
您似乎正在从IPython笔记本中访问sklearn2pmml
功能。此函数执行Java进程(从错误报告的最后一行可以看出),并检查此Java进程是返回退出代码0(成功)还是-1(失败)。
返回退出代码-1的最可能原因是抛出了某种Java异常。 Java进程将这些异常的完整堆栈跟踪打印到其标准&#34;输出流。显然,IPython笔记本并不知道如何捕获和传输它 - 你只是看到了Python的前端&#34;例外,而不是Java&#34;后端&#34;异常。
您的错误报告不包含任何可操作的信息(并且不是可重现的示例)。请检查您的IPython笔记本的原始日志,看看Java&#34;后端&#34;异常真的是。如果直接从命令行执行Python脚本会发生什么?