Я пытаюсь сохранить объект Pipeline как PMML, и Python генерирует RuntimeError.
Моя версия Python 3.6
, sklearn2pmml
версия 0.44.0
и версия JDK 1.8.0_201
.
Все это соответствует предпосылкам пакета.
Вот что я сделал до сих пор.(Я не включаю часть загрузки и очистки данных)
from sklearn2pmml.pipeline import PMMLPipeline
from sklearn2pmml import make_pmml_pipeline, sklearn2pmml
logit_pipline = Pipeline([('vect', CountVectorizer(ngram_range=(1,2))), ('tfidf', TfidfTransformer(use_idf=True)), ('clf', LogisticRegression(C=11.3))])
pmml_pipeline = PMMLPipeline([("logit", logit_pipline)])
pmml_pipeline.fit(X, Y)
sklearn2pmml(pmml_pipeline, 'logit.pmml', with_repr=True)
Что происходит после того, как я запустил последнюю строку, упомянутую выше, это ...
sklearn2pmml(pmml_pipeline, 'logit.pmml', with_repr=True)
Standard output is empty
Standard error:
Apr 30, 2019 11:59:04 AM org.jpmml.sklearn.Main run
INFO: Parsing PKL..
Apr 30, 2019 11:59:04 AM org.jpmml.sklearn.Main run
INFO: Parsed PKL in 230 ms.
Apr 30, 2019 11:59:04 AM org.jpmml.sklearn.Main run
INFO: Converting..
Apr 30, 2019 11:59:04 AM org.jpmml.sklearn.Main run
SEVERE: Failed to convert
java.lang.IllegalArgumentException: Expected an estimator object as the last step, got a transformer object (Python class sklearn.pipeline.Pipeline)
at sklearn2pmml.pipeline.PMMLPipeline.getEstimator(PMMLPipeline.java:541)
at sklearn2pmml.pipeline.PMMLPipeline.encodePMML(PMMLPipeline.java:93)
at org.jpmml.sklearn.Main.run(Main.java:145)
at org.jpmml.sklearn.Main.main(Main.java:94)
Exception in thread "main" java.lang.IllegalArgumentException: Expected an estimator object as the last step, got a transformer object (Python class sklearn.pipeline.Pipeline)
at sklearn2pmml.pipeline.PMMLPipeline.getEstimator(PMMLPipeline.java:541)
at sklearn2pmml.pipeline.PMMLPipeline.encodePMML(PMMLPipeline.java:93)
at org.jpmml.sklearn.Main.run(Main.java:145)
at org.jpmml.sklearn.Main.main(Main.java:94)
Traceback (most recent call last):
File "<ipython-input-129-f5c307b4aaba>", line 1, in <module>
sklearn2pmml(pmml_pipeline, 'logit.pmml', with_repr=True)
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn2pmml\__init__.py", line 252, 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
Теперь, по мнению некоторых людейЭто - некоторая проблема совместимости с JDK, и использование JDK версий 1.9 и выше или 1.6 и ниже создает такие проблемы.Но так как моя версия JDK приемлема для sklearn2pmml, почему возникает такая ошибка?