write_literanger {literanger} | R Documentation |
Serialize random forest
Description
Write a random forest to a file or connection using light-weight serialization for C++ objects.
Usage
write_literanger(object, file, verbose = FALSE, ...)
Arguments
object |
A trained random forest |
file |
A connection or the name of the file where the |
verbose |
Show additional serialization information (not implemented). |
... |
Further arguments passed to |
Details
This function uses 'cereal' light-weight serialization to
write a literanger object (random forest) to a file or connection. The
file can be read in via read_literanger()
and used for prediction
with no requirement for the original training data.
Author(s)
stephematician stephematician@gmail.com
See Also
Examples
## Classification forest
train_idx <- sample(nrow(iris), 2/3 * nrow(iris))
iris_train <- iris[ train_idx, ]
iris_test <- iris[-train_idx, ]
lr_iris <- train(data=iris_train, response_name="Species")
file <- tempfile()
write_literanger(lr_iris, file)
lr_copy <- read_literanger(file)
pred_bagged <- predict(lr_copy, newdata=iris_test, prediction_type="bagged")
[Package literanger version 0.2.0 Index]