Python sklearn 导出PMML报错

一 报错

二月 28, 2021 12:12:21 下午 org.jpmml.sklearn.Main run
严重: Failed to convert PKL to PMML
java.lang.IllegalArgumentException: Attribute 'sklearn.linear_model._logistic.LogisticRegression.multi_class' must be explicitly set to the 'ovr' or 'multinomial' value
	at sklearn.linear_model.logistic.LogisticRegression.encodeModel(LogisticRegression.java:58)
	at sklearn.Estimator.encode(Estimator.java:83)
	at sklearn2pmml.pipeline.PMMLPipeline.encodePMML(PMMLPipeline.java:233)
	at org.jpmml.sklearn.Main.run(Main.java:233)
	at org.jpmml.sklearn.Main.main(Main.java:151)

Exception in thread "main" java.lang.IllegalArgumentException: Attribute 'sklearn.linear_model._logistic.LogisticRegression.multi_class' must be explicitly set to the 'ovr' or 'multinomial' value
	at sklearn.linear_model.logistic.LogisticRegression.encodeModel(LogisticRegression.java:58)
	at sklearn.Estimator.encode(Estimator.java:83)
	at sklearn2pmml.pipeline.PMMLPipeline.encodePMML(PMMLPipeline.java:233)
	at org.jpmml.sklearn.Main.run(Main.java:233)
	at org.jpmml.sklearn.Main.main(Main.java:151)

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-14-1492e78f6772> in <module>
      7 pipeline.fit(X_train, y_train)
      8 print('测试准确率是{}:'.format(pipeline.score(X_test, y_test)))
----> 9 sklearn2pmml(pipeline, "SkLearnLR.pmml")
     10 print ('over')

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn2pmml/__init__.py in sklearn2pmml(pipeline, pmml, user_classpath, with_repr, debug, java_encoding)
    256                                 print("Standard error is empty")
    257                 if retcode:
--> 258                         raise RuntimeError("The JPMML-SkLearn conversion application has failed. The Java executable should have printed more information about the failure into its standard output and/or standard error streams")
    259         finally:
    260                 if debug:

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

二 修改

pipeline= PMMLPipeline([('LogisticModer', LogisticRegression())])

修改:

pipeline= PMMLPipeline([('LogisticModer', LogisticRegression(multi_class='ovr'))])

第一次使用,还是要去看文档:

scikit-learn中的逻辑回归默认支持多分类问题,分类方式为 'OvR';

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值