Reputation: 130
I am trying to export an xgboost model from R to PMML. This PMML model will be integrated into a Java-based electronic medical record (EMR) system. I have tried everything and keep getting the following error:
Error in .convert(tempfile, file, converter, converter_classpath, verbose): Java is not installed, or the Java executable is not on system path (error code 127)
I am working with Windows 10, 64-bit machine, and have tried the following:
r2pmml
from source to get the latest version; updated R to the latest versionI am not even able to replicate this example from the r2pmml
documentation. I get the same Java error as above:
library("xgboost")
library("r2pmml")
data(iris)
iris_X = iris[, -ncol(iris)]
iris_y = iris[, ncol(iris)]
# Convert from factor to integer[0, num_class]
iris_y = (as.integer(iris_y) - 1)
iris.matrix = model.matrix(~ . - 1, data = iris_X)
iris.DMatrix = xgb.DMatrix(iris.matrix, label = iris_y)
iris.fmap = as.fmap(iris.matrix)
iris.xgboost = xgboost(data = iris.DMatrix,
objective = "multi:softprob", num_class = 3, nrounds = 11)
iris.xgboost = decorate(iris.xgboost, iris.fmap,
response_name = "Species", response_levels = c("setosa", "versicolor", "virginica"))
pmmlFile = file.path(tempdir(), "Iris-XGBoost.pmml")
r2pmml(iris.xgboost, pmmlFile, compact = FALSE)
compactPmmlFile = file.path(tempdir(), "Iris-XGBoost-compact.pmml")
r2pmml(iris.xgboost, compactPmmlFile, compact = TRUE)
Upvotes: 0
Views: 88
Reputation: 4926
Your Java setup is definitely messy. Here's how to clean it up:
rJava
package.JAVA_HOME
environment variable (GNU/Linux style; see Windows documentation for Windows style): export JAVA_HOME=/opt/jdk-11/
.bin
directory of the newly exported JAVA_HOME
env-var to the PATH
environment variable (again, the following uses GNU/Linux style): export PATH=$PATH:$JAVA_HOME/bin/
.java --version
into it, it should print out the exact version string of your JDK 11.r2pmml
package works fine now, no need for additional R level changes!You may also invoke the r2pmml::r2pmml()
utility function with the verbose = TRUE
flag on. This will print out the exact command-line sequence, which you can re-try one by one on a new terminal window and see where the original misconfiguration error resided.
Upvotes: 1