#---------------------------------------------------------------------
# iris data - classification random forest
#---------------------------------------------------------------------
# load the rfsrc object from the cached data
data(rfsrc_iris, package="ggRandomForests")
# The plot.variable call
partial_iris <- plot.variable(rfsrc_iris,
partial=TRUE, show.plots=FALSE)
# plot the forest partial plots
gg_dta <- gg_partial(partial_iris)
plot(gg_dta, panel=TRUE)
#---------------------------------------------------------------------
# airq data - regression random forest
#---------------------------------------------------------------------
# load the rfsrc object from the cached data
data(rfsrc_airq, package="ggRandomForests")
# The plot.variable call
partial_airq <- plot.variable(rfsrc_airq,
partial=TRUE, show.plots=FALSE)
# plot the forest partial plots
gg_dta <- gg_partial(partial_airq)
plot(gg_dta, panel=TRUE)
#---------------------------------------------------------------------
# mtcars data - regression random forest
#---------------------------------------------------------------------
# load the rfsrc object from the cached data
data(rfsrc_mtcars, package="ggRandomForests")
# The plot.variable call
partial_mtcars <- plot.variable(rfsrc_mtcars,
partial=TRUE, show.plots=FALSE)
# plot the forest partial plots
gg_dta <- gg_partial(partial_mtcars)
plot(gg_dta, panel=TRUE)
#---------------------------------------------------------------------
# MASS::Boston data - regression random forest
#---------------------------------------------------------------------
# load the rfsrc object from the cached data
data(rfsrc_Boston, package="ggRandomForests")
# The plot.variable call
partial_Boston <- plot.variable(rfsrc_Boston,
partial=TRUE, show.plots = FALSE )
# plot the forest partial plots
gg_dta <- gg_partial(partial_Boston)
plot(gg_dta, panel=TRUE)
#---------------------------------------------------------------------
# randomForestSRC::pbc data - survival random forest
#---------------------------------------------------------------------
# load the rfsrc object from the cached data
data(rfsrc_pbc, package="ggRandomForests")
# The plot.variable call -
# survival requires a time point specification.
# for the pbc data, we want 1, 3 and 5 year survival.
partial_pbc <- lapply(c(1,3,5), function(tm){
plot.variable(rfsrc_pbc, surv.type = "surv",
time = tm,
xvar.names = xvar,
partial = TRUE,
show.plots = FALSE)
})
# plot the forest partial plots
gg_dta <- gg_partial(partial_pbc)
plot(gg_dta)
#---------------------------------------------------------------------
# randomForestSRC::veteran data - survival random forest
#---------------------------------------------------------------------
#' # load the rfsrc object from the cached data
data(rfsrc_veteran, package="ggRandomForests")
# The plot.variable call
partial_veteran <- lapply(c(30,180), function(tm){
plot.variable(rfsrc_veteran,
surv.type = "surv",
partial = TRUE,
time=tm,
show.plots=FALSE)
})
# plot the forest partial plots
gg_dta <- gg_partial(partial_veteran)
plot(gg_dta, panel=TRUE)
Run the code above in your browser using DataLab