Learn R Programming

ggRandomForests (version 1.0.0)

plot.gg_error: Plot a gg_error object

Description

A plot of the cumulative OOB error rates of the random forest as a function of number of trees.

Usage

## S3 method for class 'gg_error':
plot(x, ...)

Arguments

x
gg_error object created from a randomForestSRC object
...
extra arguments

Value

  • ggplot graph

Details

The gg_error plot is used to track the convergence of the randomForest. This figure is a reproduction of the error plot from the randomForestSRC::plot.rfsrc function.

References

Breiman L. (2001). Random forests, Machine Learning, 45:5-32.

Ishwaran H. and Kogalur U.B. (2007). Random survival forests for R, Rnews, 7(2):25-31.

Ishwaran H. and Kogalur U.B. (2013). Random Forests for Survival, Regression and Classification (RF-SRC), R package version 1.4.

See Also

gg_error randomForestSRC::rfsrc randomForestSRC::plot.rfsrc

Examples

Run this code
#' ## Examples from RFSRC package...
## ------------------------------------------------------------
## classification example
## ------------------------------------------------------------
## You can build a randomForest
# iris_rf <- rfsrc(Species ~ ., data = iris)
# ... or load a cached randomForestSRC object
data(iris_rf, package="ggRandomForests")

# Get a data.frame containing error rates
ggrf.obj<- gg_error(iris_rf)

# Plot the gg_error object
plot(ggrf.obj)

## ------------------------------------------------------------
## Regression example
## ------------------------------------------------------------
# airq_rf <- rfsrc(Ozone ~ ., data = airquality, na.action = "na.impute")
# ... or load a cached randomForestSRC object
data(airq_rf, package="ggRandomForests")

# Get a data.frame containing error rates
ggrf.obj<- gg_error(airq_rf)

# Plot the gg_error object
plot(ggrf.obj)

## ------------------------------------------------------------
## Survival example
## ------------------------------------------------------------
## veteran data
## randomized trial of two treatment regimens for lung cancer
# data(veteran, package = "randomForestSRC")
# veteran_rf <- rfsrc(Surv(time, status) ~ ., data = veteran, ntree = 100)

# Load a cached randomForestSRC object
data(veteran_rf, package="ggRandomForests")

ggrf.obj <- gg_error(veteran_rf)
plot(ggrf.obj)

Run the code above in your browser using DataLab