saveForest: Save Random Forests

Description Usage Arguments See Also Examples

View source: R/saveForest.R

Description

Saves a random forest for later use, given that the base R save function doesn't work for this package.

Usage

1
saveForest(forest, directory, overwrite = FALSE)

Arguments

forest

The forest to save.

directory

The directory that should be created to save the trees in. Note that if the directory already exists, an error will be displayed unless overwrite is set to TRUE.

overwrite

Should the function overwrite an existing forest; FALSE by default.

See Also

train, loadForest

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Regression Example
x1 <- rnorm(1000)
x2 <- rnorm(1000)
y <- 1 + x1 + x2 + rnorm(1000)

data <- data.frame(x1, x2, y)
forest <- train(y ~ x1 + x2, data,
 ntree=100, numberOfSplits = 5, mtry = 1, nodeSize = 5)

saveForest(forest, "saved_forest")
new_forest <- loadForest("saved_forest")

jatherrien/largeRCRF documentation built on Nov. 15, 2019, 7:16 a.m.