Description Usage Arguments Value See Also Examples
When a 'foresty' object is saved and then reloaded ,the Cpp pointers for the data set and the Cpp forest have to be reconstructed.
1 | make_savable(object)
|
object |
A trained model object of class "forestry". |
A list of lists. Each sublist contains the information to span a tree.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | set.seed(323652639)
x <- iris[, -1]
y <- iris[, 1]
forest <- forestry(x, y, ntree = 3)
y_pred_before <- predict(forest, x)
forest <- make_savable(forest)
save(forest, file = "forest.Rda")
rm(forest)
load("forest.Rda", verbose = FALSE)
forest <- relinkCPP_prt(forest)
y_pred_after <- predict(forest, x)
testthat::expect_equal(y_pred_before, y_pred_after, tolerance = 0.000001)
file.remove("forest.Rda")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.