if (FALSE) {
#---------------------------------------------------------------------
# iris data - classification random forest
#---------------------------------------------------------------------
# rfsrc grow call
rfsrc_iris <- rfsrc(Species ~., data = iris)
# plot the forest generalization error convergence
gg_dta <- gg_error(rfsrc_iris)
plot(gg_dta)
# Plot the forest predictions
gg_dta <- gg_rfsrc(rfsrc_iris)
plot(gg_dta)
#---------------------------------------------------------------------
# MASS::Boston data - regression random forest
#---------------------------------------------------------------------
# Load the data...
data(Boston, package="MASS")
Boston$chas <- as.logical(Boston$chas)
# rfsrc grow call
rfsrc_boston <- rfsrc(medv~., data=Boston)
# plot the forest generalization error convergence
gg_dta <- gg_error(rfsrc_boston)
plot(gg_dta)
# Plot the forest predictions
gg_dta <- gg_rfsrc(rfsrc_boston)
plot(gg_dta)
#---------------------------------------------------------------------
# randomForestSRC::pbc data - survival random forest
#---------------------------------------------------------------------
# Load the data...
# For simplicity here. We do a bit of data tidying
# before running the stored random forest.
data(pbc, package="randomForestSRC")
# Remove non-randomized cases
dta.train <- pbc[-which(is.na(pbc$treatment)),]
# rfsrc grow call
rfsrc_pbc <- rfsrc(Surv(years, status) ~ ., dta.train, nsplit = 10,
na.action="na.impute")
# plot the forest generalization error convergence
gg_dta <- gg_error(rfsrc_pbc)
plot(gg_dta)
# Plot the forest predictions
gg_dta <- gg_rfsrc(rfsrc_pbc)
plot(gg_dta)
}
Run the code above in your browser using DataLab