ggRandomForests provides ggplot2 (Wickham 2009)
diagnostic and exploration figures for random forests grown with
rfsrc (>= 3.4.0) or
randomForest.
randomForestSRC gives a unified treatment of Breiman's (2001) random
forests across data settings: regression and classification forests when the
response is numeric or categorical, survival and competing-risk forests
(Ishwaran et al. 2008) for right-censored data.
Details
The package is built on one decision: keep the data step and the figure step
apart. A gg_* function pulls a tidy data object out of the forest; its
plot() method turns that object into a figure. Two things follow.
The data object stands on its own. It carries everything its plot needs, so you can save it, inspect it, or come back to it later without keeping the original forest – which can be large – in memory.
You are never locked into the default figure. Each plot() method
returns a single plottable object: a ggplot you extend with +,
or a patchwork composite for the multi-panel methods. Add layers, swap
scales, apply a theme – or ignore the default entirely and build the figure
from the tidy data yourself. Every gg_* object also carries
print() and summary() methods: print() shows a short
header rather than dumping every row, and summary() returns a
diagnostics object.
Forest diagnostics
gg_rfsrc: predicted versus observed values.gg_error: OOB error against the number of trees.gg_vimp: variable importance ranking (Ishwaran et al. 2010).gg_variable: marginal variable dependence.gg_roc: ROC curves for classification forests (see alsocalc_rocandcalc_auc).gg_survival: Kaplan-Meier / Nelson-Aalen estimates.gg_brier: time-resolved Brier score and CRPS for survival forests.
Partial dependence
gg_partial: tidies the output ofrandomForestSRC::plot.variable(partial = TRUE).gg_partial_rfsrc: computes partial dependence from the fitted forest directly, viapartial.rfsrc.
SHAP explanations
gg_shap: SHAP values for regression and classification forests, wrappingkernelshap, withshap_importance,shap_beeswarmandshap_dependencefigures.
varPro rule-based variable selection
gg_varpro: variable importance from avarprofit.gg_partial_varpro(aliasgg_partialpro): partial effects on an interpretable scale.gg_beta_varpro: per-region lasso coefficients.gg_isopro: isolation-forest outlier scores.gg_ivarpro: individual (per-observation) importance.
Unsupervised varPro
gg_udependent: variable dependency graph.gg_beta_uvarpro: entropy-based variable ranking.gg_sdependent: signal-variable detection.
varPro is a required dependency (Imports), so the varPro
families are always available. kernelshap is in Suggests:
gg_shap checks for it and fails with a clear message when it
is not installed.
References
Breiman, L. (2001). Random forests, Machine Learning, 45:5-32.
Ishwaran H. and Kogalur U.B. randomForestSRC: Random Forests for Survival, Regression and Classification. R package version >= 3.4.0. https://cran.r-project.org/package=randomForestSRC
Ishwaran H. and Kogalur U.B. (2007). Random survival forests for R. R News 7(2), 25–31.
Ishwaran H., Kogalur U.B., Blackstone E.H. and Lauer M.S. (2008). Random survival forests. Ann. Appl. Statist. 2(3), 841–860.
Ishwaran, H., U. B. Kogalur, E. Z. Gorodeski, A. J. Minn, and M. S. Lauer (2010). High-dimensional variable selection for survival data. J. Amer. Statist. Assoc. 105, 205-217.
Ishwaran, H. (2007). Variable importance in binary regression trees and forests. Electronic J. Statist., 1, 519-537.
Wickham, H. ggplot2: elegant graphics for data analysis. Springer New York, 2009.