make_savable {Rforestry} | R Documentation |
make_savable
Description
When a 'foresty' object is saved and then reloaded the Cpp pointers for the data set and the Cpp forest have to be reconstructed
Usage
make_savable(object)
Arguments
object |
an object of class 'forestry' |
Value
A list of lists. Each sublist contains the information to span a tree.
Note
'make_savable' does not translate all of the private member variables of the C++ forestry object so when the forest is reconstructed with 'relinkCPP_prt' some attributes are lost. For example, 'nthreads' will be reset to zero. This makes it impossible to disable threading when predicting for forests loaded from disk.
Examples
set.seed(323652639)
x <- iris[, -1]
y <- iris[, 1]
forest <- forestry(x, y, ntree = 3, nthread = 2)
y_pred_before <- predict(forest, x)
forest <- make_savable(forest)
wd <- tempdir()
saveForestry(forest, filename = file.path(wd, "forest.Rda"))
rm(forest)
forest <- loadForestry(file.path(wd, "forest.Rda"))
y_pred_after <- predict(forest, x)
file.remove(file.path(wd, "forest.Rda"))
[Package Rforestry version 0.10.0 Index]