Closed pjpan closed 7 years ago
This issue has been fixed in the JPMML-XGBoost library: https://github.com/jpmml/jpmml-xgboost/commit/ec4bdc669d625dabb34fd63ae24f516d1092428c
thanks,it solved the problem.
@vruusmann why can't directly use function r2pmml to save the train model ,such as r2pmml(iris.xgb, fmap = iris.fmap, "iris_xgb.pmml")
why can't directly use function r2pmml to save the train model
@AlexYoung757 Why can't you, is there some sort of exception being thrown?
Please note that the ordering or parameters has changed in recent r2pmml
package versions. You need to specify the name of the output PMML file as the second argument, and the feature map as the third argument:
r2pmml(iris.xgb, "iris_xgb.pmml", fmap = iris.fmap)
@vruusmann thank you . I update the latest version , it can works well
xgboost version: 0.6-0
error message:
Exception in thread "main" java.lang.IllegalArgumentException: java.io.IOException at org.jpmml.rexp.XGBoostConverter.encodeModel(XGBoostConverter.java:90) at org.jpmml.rexp.XGBoostConverter.encodeModel(XGBoostConverter.java:40) at org.jpmml.rexp.ModelConverter.encodePMML(ModelConverter.java:90) at org.jpmml.rexp.ModelConverter.encodePMML(ModelConverter.java:74) at org.jpmml.rexp.Main.run(Main.java:149) at org.jpmml.rexp.Main.main(Main.java:97) Caused by: java.io.IOException at org.jpmml.xgboost.XGBoostDataInput.readReserved(XGBoostDataInput.java:68) at org.jpmml.xgboost.Learner.load(Learner.java:59) at org.jpmml.xgboost.XGBoostUtil.loadLearner(XGBoostUtil.java:34) at org.jpmml.rexp.XGBoostConverter.loadLearner(XGBoostConverter.java:159) at org.jpmml.rexp.XGBoostConverter.encodeModel(XGBoostConverter.java:88) ... 5 more Picked up _JAVA_OPTIONS: -Xmx16G Error in .convert(tempfile, file, ...) : 1 In addition: Warning message: running command '"java" -cp "C:/Program Files/R/R-3.3.1/library/r2pmml/java/guava-19.0.jar;"
R code,just use your example;
library("xgboost") library("r2pmml") data(iris) iris_x = iris[, 1:4] iris_y = as.integer(iris[, 5]) - 1
Train a model
iris.xgb = xgboost(data = as.matrix(iris_x), label = iris_y, objective = "multi:softmax", num_class = 3, nrounds = 13)
Create a feature map
iris.fmap = data.frame( "id" = seq(from = 0, (to = ncol(iris_x) - 1)), "name" = names(iris_x), "type" = rep("q", ncol(iris_x)) )
Export the model to PMML.
Pass the feature map as the
fmap
argumentr2pmml(iris.xgb, fmap = iris.fmap, "iris_xgb.pmml")