% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.gg_roc.R
\name{plot.gg_roc}
\alias{plot.gg_roc}
\title{ROC plot generic function for a \code{\link{gg_roc}} object.}
\usage{
\method{plot}{gg_roc}(x, which_outcome = NULL, ..., panel = c("overlay", "facet"))
}
\arguments{
\item{x}{A \code{\link{gg_roc}} object, or a raw
\code{\link[randomForestSRC]{rfsrc}} or
\code{\link[randomForest]{randomForest}} classification forest. Hand it a
forest and \code{\link{gg_roc}} is called for you.}

\item{which_outcome}{Integer; for multi-class problems, the index of the
class to plot. When \code{NULL} (default) and the forest has more than two
classes, the curves for all classes are overlaid in one plot. For binary
forests, \code{NULL} defaults to class index 2.}

\item{...}{Additional arguments passed to \code{\link{gg_roc}} when
\code{x} is a raw forest (e.g. \code{oob = FALSE}).}

\item{panel}{Character; layout for per-class ROC objects, the ones from
\code{gg_roc(..., per_class = TRUE)}. \code{"overlay"} (default) draws
every class curve in one panel, coloured by class; \code{"facet"} gives
each class its own panel. Ignored for single-class \code{gg_roc} objects.}
}
\value{
A \code{ggplot} object. The x-axis is 1 - Specificity (FPR), the
y-axis is Sensitivity (TPR), and a dashed red diagonal marks the
random-classifier baseline. Single-class curves carry the AUC as an
annotation; multi-class plots colour and style each class curve
distinctly.
}
\description{
ROC plot generic function for a \code{\link{gg_roc}} object.
}
\examples{
## ------------------------------------------------------------
## classification example
## ------------------------------------------------------------
## -------- iris data
# Build a small classification forest (ntree=50 keeps example fast)
set.seed(42)
rfsrc_iris <- randomForestSRC::rfsrc(Species ~ ., data = iris, ntree = 50)

# ROC for setosa (outcome index 1)
gg_dta <- gg_roc(rfsrc_iris, which_outcome = 1)
plot(gg_dta)

# ROC for versicolor (outcome index 2)
gg_dta <- gg_roc(rfsrc_iris, which_outcome = 2)
plot(gg_dta)

# ROC for virginica (outcome index 3)
gg_dta <- gg_roc(rfsrc_iris, which_outcome = 3)
plot(gg_dta)

# Plot all three ROC curves in one call by iterating over outcome indices
n_cls <- ncol(rfsrc_iris$predicted)
for (i in seq_len(n_cls)) print(plot(gg_roc(rfsrc_iris, which_outcome = i)))

}
\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. randomForestSRC: Random Forests for Survival,
Regression and Classification. R package version >= 3.4.0.
\url{https://cran.r-project.org/package=randomForestSRC}
}
\seealso{
\code{\link{gg_roc}} \code{\link{calc_roc}} \code{\link{calc_auc}}
\code{\link[randomForestSRC]{rfsrc}}
\code{\link[randomForest]{randomForest}}
}
