write_literanger | R Documentation |
Write a random forest to a file or connection using light-weight serialization for C++ objects.
write_literanger(object, file, verbose = TRUE, ...)
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 |
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.
stephematician stephematician@gmail.com
read_literanger()
saveRDS
## Classification forest
train_idx <- sample(nrow(iris), 2/3 * nrow(iris))
iris_train <- iris[ train_idx, ]
iris_test <- iris[-train_idx, ]
rf_iris <- train(data=iris_train, response_name="Species")
file <- tempfile()
write_literanger(rf_iris, file)
rf_copy <- read_literanger(file)
pred_bagged <- predict(rf_copy, newdata=iris_test, prediction_type="bagged")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.