Closed edumucelli closed 7 years ago
@edumucelli Thanks for providing a reproducible example. However, I have a slight problem running it in my computer, as the train()
function complains about some bad arguments:
> model_fit = train(CLASS ~ ., data = train, method = "glm", trControl = crtl, tuneLength = tune_length, metric = "ROC")
Error in apply(testOutput[, lev], 1, function(x) x/sum(x)) :
dim(X) must have a positive length
Can you figure out what's causing it?
The opcode 17
corresponds to a "dot-dot-dot" object. My RDS parser doesn't recognize this opcode yet. However, when needed, it shouldn't be difficult to implement.
As a temporary workaround, can you execute the r2pmml()
function with just the fitted glm()
object, which is accessible as model_fit$finalModel
?
r2pmml(model_fit$finalModel, ...)
This way you won't be serializing the whole train()
object, which means that there's a good chance that the temporary RDS file won't contain any "dot-dot-dot" objects, and the conversion should succeed.
@vruusmann thank you for the quick response. Thanks for the further info regarding the problematic of the "...". Please find bellow the fixed version of the reproducible example. Unfortunately the error is the same. Let me know if you want me to test something else.
library(caret)
library("r2pmml")
NROW = 2000
NCOL = 5
data = data.frame(CLASS = replicate(1, sample(c('true', 'false'), replace=TRUE)), replicate(NCOL, sample(rnorm(NROW), replace=TRUE)))
trainIndex <- createDataPartition(data$CLASS, p = .75, times = 1, list = FALSE)
train <- data[ trainIndex,]
test <- data[-trainIndex,]
method = "glm"
crtl = trainControl(method = "repeatedcv",
number = 10,
repeats = 1,
verboseIter = TRUE,
returnData = FALSE)
tune_length = 3
method_fit = train(CLASS ~.,
data = data,
method = method,
trControl = crtl,
tuneLength = tune_length)
r2pmml(method_fit, paste0("glm.benchmark.", NCOL, ".pmml"))
# Unfortunately using finalModel did not worked either
r2pmml(method_fit$finalModel, paste0("glm.benchmark.", NCOL, ".pmml"))
@vruusmann I am experiencing a similar error as presented on #8, but this time when using GLM with caret. Follow are the error, the reproducible code and the
sessionInfo()
. Maybe I am misusing r2pmml here with features that are specifically not supported. In this case, I'd be thankful if you could point me out which are them.All the JPMML environment is an excellent tool, congratulations.