jpmml / sklearn2pmml

Python library for converting Scikit-Learn pipelines to PMML
GNU Affero General Public License v3.0
685 stars 113 forks source link

Generate pmml file error when using adaboost #40

Closed fndjjx closed 7 years ago

fndjjx commented 7 years ago

Hi When I use sklearn2pmml for AdaboostClassifier, it generate some errors. My script is just same like the example except the classifier. I change the classifier to randomforest or other models, it works well. Could you kindly help me to find out what's the problem? thank you My version is:

>>> import sklearn2pmml
>>> sklearn2pmml.__version__
'0.20.3'

python:

import pandas

iris_df = pandas.read_csv("iris.csv")

from sklearn2pmml import PMMLPipeline
from sklearn2pmml.decoration import ContinuousDomain
from sklearn_pandas import DataFrameMapper
from sklearn.decomposition import PCA
from sklearn.feature_selection import SelectKBest
from sklearn.preprocessing import Imputer
from sklearn.linear_model import LogisticRegression

from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier,AdaBoostRegressor

iris_pipeline = PMMLPipeline([
        ("mapper", DataFrameMapper([
                (["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"], [ContinuousDomain(), Imputer()])
        ])),
        ("pca", PCA(n_components = 3)),
        ("selector", SelectKBest(k = 2)),
        ("classifier", AdaBoostClassifier())
])
iris_pipeline.fit(iris_df, iris_df["Species"])

from sklearn2pmml import sklearn2pmml

sklearn2pmml(iris_pipeline, "model.pmml", with_repr = True)

and the error is:

java -cp /home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jpmml-sklearn-1.3.3.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/pyrolite-4.19.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/pmml-agent-1.3.6.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/slf4j-api-1.7.25.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jcommander-1.48.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jaxb-core-2.2.11.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/istack-commons-runtime-2.21.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jaxb-runtime-2.2.11.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/pmml-model-metro-1.3.6.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/guava-20.0.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/serpent-1.18.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/pmml-schema-1.3.6.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/slf4j-jdk14-1.7.25.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/pmml-model-1.3.6.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jpmml-converter-1.2.3.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jpmml-lightgbm-1.0.7.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jpmml-xgboost-1.1.7.jar org.jpmml.sklearn.Main --pkl-pipeline-input /tmp/pipeline-gtq64tqp.pkl.z --pmml-output model.pmml
Jun 19, 2017 11:50:19 AM org.jpmml.sklearn.Main run
INFO: Parsing PKL..
Jun 19, 2017 11:50:19 AM org.jpmml.sklearn.Main run
INFO: Parsed PKL in 119 ms.
Jun 19, 2017 11:50:19 AM org.jpmml.sklearn.Main run
INFO: Converting..
Jun 19, 2017 11:50:19 AM org.jpmml.sklearn.Main run
SEVERE: Failed to convert
java.lang.IllegalArgumentException
    at sklearn2pmml.PMMLPipeline.encodePMML(PMMLPipeline.java:74)
    at org.jpmml.sklearn.Main.run(Main.java:144)
    at org.jpmml.sklearn.Main.main(Main.java:93)

Exception in thread "main" java.lang.IllegalArgumentException
    at sklearn2pmml.PMMLPipeline.encodePMML(PMMLPipeline.java:74)
    at org.jpmml.sklearn.Main.run(Main.java:144)
    at org.jpmml.sklearn.Main.main(Main.java:93)
Traceback (most recent call last):
  File "/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/__init__.py", line 142, in sklearn2pmml
    subprocess.check_call(cmd)
  File "/home/ly/anaconda3/lib/python3.5/subprocess.py", line 581, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['java', '-cp', '/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jpmml-sklearn-1.3.3.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/pyrolite-4.19.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/pmml-agent-1.3.6.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/slf4j-api-1.7.25.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jcommander-1.48.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jaxb-core-2.2.11.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/istack-commons-runtime-2.21.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jaxb-runtime-2.2.11.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/pmml-model-metro-1.3.6.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/guava-20.0.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/serpent-1.18.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/pmml-schema-1.3.6.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/slf4j-jdk14-1.7.25.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/pmml-model-1.3.6.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jpmml-converter-1.2.3.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jpmml-lightgbm-1.0.7.jar:/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/resources/jpmml-xgboost-1.1.7.jar', 'org.jpmml.sklearn.Main', '--pkl-pipeline-input', '/tmp/pipeline-gtq64tqp.pkl.z', '--pmml-output', 'model.pmml']' returned non-zero exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test6.py", line 27, in <module>
    sklearn2pmml(iris_pipeline, "model.pmml", with_repr = True)
  File "/home/ly/.local/lib/python3.5/site-packages/sklearn2pmml/__init__.py", line 144, in sklearn2pmml
    raise RuntimeError("The JPMML-SkLearn conversion application has failed. The Java process should have printed more information about the failure into its standard output and/or error streams")
RuntimeError: The JPMML-SkLearn conversion application has failed. The Java process should have printed more information about the failure into its standard output and/or error streams
vruusmann commented 7 years ago

Duplicate of: https://github.com/jpmml/jpmml-sklearn/issues/41

Python class sklearn.ensemble.AdaBoostClassifier is not supported, because its predict(X) and predict_proba(X) methods yield inconsistent results.