Closed simonpcouch closed 2 years ago
Just documenting a quick look into whether we need to support caret. From my understanding, caret handles serialization by serializing objects that need it and, at predict time, temporarily unserializing them.
library(caret) #> Loading required package: ggplot2 #> Loading required package: lattice predictors <- mtcars[, c("cyl", "disp", "hp")] set.seed(1) suppressMessages(suppressWarnings( fit <- train( x = predictors, y = mtcars$mpg, method = "mlpKerasDecay", verbose = 0 ) )) callr::r( function(fit, predictors) { library(caret) predict(fit, predictors) }, args = list(fit = fit, predictors = predictors) ) #> [1] -38.6654625 -38.6654625 -17.0129700 -92.0914993 -117.8382492 #> [6] -76.5140152 -84.0575333 -53.0708122 -33.9291649 -36.5351295 #> [11] -36.5351295 -69.5225601 -69.5225601 -69.5225601 -164.4191284 #> [16] -153.0513000 -134.9093323 -14.0693846 -19.1900330 -10.4087210 #> [21] -21.6791229 -107.0059433 -99.3736343 -78.6058884 -139.6448059 #> [26] -14.2329397 -24.6836357 -0.3287155 -69.9819717 0.8798035 #> [31] -8.4605131 -16.3787842
Created on 2022-07-15 by the reprex package (v2.0.1)
So, good to go. :)
With a train object, x$finalModel would be the slot serialize.
x$finalModel
Just documenting a quick look into whether we need to support caret. From my understanding, caret handles serialization by serializing objects that need it and, at predict time, temporarily unserializing them.
Created on 2022-07-15 by the reprex package (v2.0.1)
So, good to go. :)