Attribute ‘sklearn.linear_model._logistic.LogisticRegression.multi_class‘ must be explicitly set to

试图python模型转化为java加载,碰到个硬茬,完整报错信息如下:

Jul 13, 2020 3:13:45 PM org.jpmml.sklearn.Main run
INFO: Parsing PKL..
Jul 13, 2020 3:13:45 PM org.jpmml.sklearn.Main run
INFO: Parsed PKL in 14 ms.
Jul 13, 2020 3:13:45 PM org.jpmml.sklearn.Main run
INFO: Converting..
Jul 13, 2020 3:13:45 PM sklearn2pmml.pipeline.PMMLPipeline initTargetFields
WARNING: Attribute 'sklearn2pmml.pipeline.PMMLPipeline.target_fields' is not set. Assuming y as the name of the target field
Jul 13, 2020 3:13:45 PM sklearn2pmml.pipeline.PMMLPipeline initActiveFields
WARNING: Attribute 'sklearn2pmml.pipeline.PMMLPipeline.active_fields' is not set. Assuming [x1, x2, x3, x4] as the names of active fields
Jul 13, 2020 3:13:45 PM org.jpmml.sklearn.Main run
SEVERE: Failed to convert
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:57)
	at sklearn2pmml.pipeline.PMMLPipeline.encodePMML(PMMLPipeline.java:231)
	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:57)
	at sklearn2pmml.pipeline.PMMLPipeline.encodePMML(PMMLPipeline.java:231)
	at org.jpmml.sklearn.Main.run(Main.java:233)
	at org.jpmml.sklearn.Main.main(Main.java:151)

Traceback (most recent call last):
  File "train.py", line 26, in 
    sklearn2pmml(model, './LogisticRegression.pmml', with_repr=True)
  File "/home/appleyuchi/anaconda3/envs/Python3.6/lib/python3.6/site-packages/sklearn2pmml/__init__.py", line 266, in sklearn2pmml
    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")
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

 

解决方案:

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

改成:

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

你可能感兴趣的:(Python)