Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
319 views
in Technique[技术] by (71.8m points)

pmml - r2pmml unable to convert R model

After the R version and package update late last year, r2pmml is unable to convert my R model into PMML.

Below is my example copied from the GitHub r2pmml guidance, with some of the logs and error message at the end.

version[['version.string']]
*#"R version 4.0.3 (2020-10-10)"*
system("java -version")
*#java version "1.8.0_271"*
*#Java(TM) SE Runtime Environment (build 1.8.0_271-b09)*
*#Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)*
*#[1] 0*
library("ranger")
packageVersion("ranger")
*#[1] ‘0.12.1’*
library("r2pmml")
packageVersion("r2pmml")
*#[1] ‘0.22.0’*
data(iris)
iris.ranger = ranger(Species ~ ., data = iris, num.trees = 7, write.forest = TRUE)
print(iris.ranger)
r2pmml(iris.ranger, "iris_ranger.pmml", data = iris)
*#Jan 21, 2021 2:42:10 PM org.jpmml.rexp.Main run*
*#INFO: Parsing RDS..*
*#Jan 21, 2021 2:42:10 PM org.jpmml.rexp.Main run*
*#INFO: Parsed RDS in 15 ms.*
*#Jan 21, 2021 2:42:10 PM org.jpmml.rexp.Main run*
*#INFO: Initializing default Converter*
*#Jan 21, 2021 2:42:10 PM org.jpmml.rexp.Main run*
*#INFO: Initialized org.jpmml.rexp.RangerConverter*
*#Jan 21, 2021 2:42:10 PM org.jpmml.rexp.Main run*
*#INFO: Converting..*
*#Jan 21, 2021 2:42:10 PM org.jpmml.rexp.Main run*
*#SEVERE: Failed to convert*
*#java.lang.ArrayIndexOutOfBoundsException: 4*
*#at org.jpmml.rexp.RBooleanVector.getValue(RBooleanVector.java:51)*
*#at org.jpmml.rexp.RangerConverter.encodeSchema(RangerConverter.java:100)*
*#at org.jpmml.rexp.ModelConverter.encodePMML(ModelConverter.java:69)*
*#at org.jpmml.rexp.Converter.encodePMML(Converter.java:39)*
*#at org.jpmml.rexp.Main.run(Main.java:149)*
*#at org.jpmml.rexp.Main.main(Main.java:97)*
 
*#Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4*
*#at org.jpmml.rexp.RBooleanVector.getValue(RBooleanVector.java:51)*
*#at org.jpmml.rexp.RangerConverter.encodeSchema(RangerConverter.java:100)*
*#at org.jpmml.rexp.ModelConverter.encodePMML(ModelConverter.java:69)*
*#at org.jpmml.rexp.Converter.encodePMML(Converter.java:39)*
*#at org.jpmml.rexp.Main.run(Main.java:149)*
*#at org.jpmml.rexp.Main.main(Main.java:97)*

Error in .convert(tempfile, file, converter, converter_classpath, verbose):

The JPMML-R conversion application has failed (error code 1). The Java executable should have printed more information about the failure into its standard output and/or standard error streams

I would appreciate any suggestions from the community to help solve this problem. Thank you.

question from:https://stackoverflow.com/questions/65831208/r2pmml-unable-to-convert-r-model

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You're likely experiencing https://github.com/jpmml/r2pmml/issues/62

packageVersion("r2pmml")

‘0.22.0’*

That's an outdated R2PMML package version (doesn't include a fix for the above issue).

Please install the latest R2PMML package from GitHub (as explained https://github.com/jpmml/r2pmml#installation), and everything should work fine.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...