write_literanger: Serialize random forest

View source: R/io.R

write_literangerR 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 = TRUE, ...)

Arguments

object

A trained random forest literanger object.

file

A connection or the name of the file where the literanger object will be saved.

verbose

Show additional serialization information (not implemented).

...

Further arguments passed to saveRDS().

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

read_literanger() saveRDS

Examples

## 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")


literanger documentation built on Sept. 30, 2024, 9:15 a.m.