% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gg_roc.R
\name{gg_roc.rfsrc}
\alias{gg_roc.rfsrc}
\alias{gg_roc}
\alias{gg_roc.randomForest}
\title{ROC (Receiver Operating Characteristic) curve data from a classification forest.}
\usage{
\method{gg_roc}{rfsrc}(object, which_outcome, oob = TRUE, ...)
}
\arguments{
\item{object}{A classification \code{\link[randomForestSRC]{rfsrc}} or
\code{\link[randomForest]{randomForest}} object. Only forests with
\code{family == "class"} (rfsrc) or \code{type == "classification"}
(randomForest) are supported.}

\item{which_outcome}{Integer index or character name of the class for which
the ROC curve is computed. For binary forests this is typically \code{1}
or \code{2}; for multi-class forests any valid class index. Use
\code{which_outcome = 0} to obtain the overall (averaged) ROC.}

\item{oob}{Logical; if \code{TRUE} (default) use out-of-bag predicted
probabilities for the curve. Set to \code{FALSE} to use full in-bag
predictions.}

\item{...}{Extra arguments (currently unused).}
}
\value{
A \code{gg_roc} \code{data.frame} with one row per unique prediction
  threshold and columns:
  \describe{
    \item{sens}{Sensitivity (true positive rate) at each threshold.}
    \item{spec}{Specificity (true negative rate) at each threshold.}
    \item{yvar}{The observed class label for each observation.}
  }
  Pass to \code{\link{calc_auc}} for the area under the curve.
}
\description{
Computes sensitivity (true positive rate) and specificity (1 - false positive
rate) across all prediction thresholds for one class of a classification
\code{\link[randomForestSRC]{rfsrc}} or
\code{\link[randomForest]{randomForest}} object.
}
\examples{
## ------------------------------------------------------------
## classification example
## ------------------------------------------------------------
## -------- iris data
rfsrc_iris <- rfsrc(Species ~ ., data = iris)

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

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

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

## -------- iris data
rf_iris <- randomForest::randomForest(Species ~ ., data = iris)

# ROC for setosa
gg_dta <- gg_roc(rf_iris, which_outcome = 1)
plot(gg_dta)

# ROC for versicolor
gg_dta <- gg_roc(rf_iris, which_outcome = 2)
plot(gg_dta)

# ROC for virginica
gg_dta <- gg_roc(rf_iris, which_outcome = 3)
plot(gg_dta)

}
\seealso{
\code{\link{plot.gg_roc}}, \code{\link{calc_roc}},
  \code{\link{calc_auc}},
  \code{\link[randomForestSRC]{rfsrc}},
  \code{\link[randomForest]{randomForest}}
}
