39 lines
1 KiB
Text
39 lines
1 KiB
Text
|
% Generated by roxygen2: do not edit by hand
|
||
|
% Please edit documentation in R/save_forest.R
|
||
|
\name{save_forest}
|
||
|
\alias{save_forest}
|
||
|
\title{Save Random Forests}
|
||
|
\usage{
|
||
|
save_forest(forest, directory, overwrite = FALSE)
|
||
|
}
|
||
|
\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
|
||
|
\code{\link{base::save}} function doesn't work for this package.
|
||
|
}
|
||
|
\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)
|
||
|
|
||
|
save_forest(forest, "trees")
|
||
|
new_forest <- load_forest("trees")
|
||
|
}
|
||
|
\seealso{
|
||
|
\code{\link{train}}, \code{\link{load_forest}}
|
||
|
}
|