2019-05-31 22:13:24 +00:00
|
|
|
% Generated by roxygen2: do not edit by hand
|
2019-06-06 22:53:25 +00:00
|
|
|
% Please edit documentation in R/saveForest.R
|
|
|
|
\name{saveForest}
|
|
|
|
\alias{saveForest}
|
2019-05-31 22:13:24 +00:00
|
|
|
\title{Save Random Forests}
|
|
|
|
\usage{
|
2019-06-06 22:53:25 +00:00
|
|
|
saveForest(forest, directory, overwrite = FALSE)
|
2019-05-31 22:13:24 +00:00
|
|
|
}
|
|
|
|
\arguments{
|
|
|
|
\item{forest}{The forest to save.}
|
|
|
|
|
|
|
|
\item{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 \code{overwrite} is set to TRUE.}
|
|
|
|
|
|
|
|
\item{overwrite}{Should the function overwrite an existing forest; FALSE by
|
|
|
|
default.}
|
|
|
|
}
|
|
|
|
\description{
|
|
|
|
Saves a random forest for later use, given that the base R
|
2019-06-30 22:07:29 +00:00
|
|
|
\code{\link[base]{save}} function doesn't work for this package.
|
2019-05-31 22:13:24 +00:00
|
|
|
}
|
|
|
|
\examples{
|
|
|
|
# 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)
|
|
|
|
|
2019-06-30 22:07:29 +00:00
|
|
|
saveForest(forest, "saved_forest")
|
|
|
|
new_forest <- loadForest("saved_forest")
|
2019-05-31 22:13:24 +00:00
|
|
|
}
|
|
|
|
\seealso{
|
2019-06-06 22:53:25 +00:00
|
|
|
\code{\link{train}}, \code{\link{loadForest}}
|
2019-05-31 22:13:24 +00:00
|
|
|
}
|