| gg_roc.rfsrc | R Documentation |
A classifier does not hand you a class; it hands you a predicted probability,
and you pick a threshold. Slide that threshold from 0 to 1 and the trade-off
between catching the positives and crying wolf shifts the whole way. The ROC
curve traces that trade-off. For one class of a classification
rfsrc or
randomForest forest, gg_roc walks every
threshold and records sensitivity (the true positive rate) against
specificity (1 minus the false positive rate).
## S3 method for class 'rfsrc'
gg_roc(object, which_outcome, oob = TRUE, per_class = FALSE, ...)
object |
A classification |
which_outcome |
Integer index or character name of the class to score.
For binary forests this is usually
|
oob |
Logical; if |
per_class |
Logical; if |
... |
Extra arguments (currently unused). |
A gg_roc data.frame, one row per unique prediction
threshold, with columns:
Sensitivity (true positive rate) at the threshold.
Specificity (true negative rate) at the threshold.
The probability threshold used for that row.
Pass it to calc_auc for the area under the curve.
plot.gg_roc, calc_roc,
calc_auc,
rfsrc,
randomForest
## ------------------------------------------------------------
## classification example
## ------------------------------------------------------------
## -------- iris data
rfsrc_iris <- randomForestSRC::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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.