| roc.curves | R Documentation |
This function plots ROC Curves of one or several classification predictions.
roc.curves(
predictions,
gt,
methods.names = NULL,
positive = levels(factor(gt))[1],
type = c("auto", "fuzzy", "hard"),
...
)
predictions |
The predictions of one or several classification models. Four shapes are
accepted: a |
gt |
Actual labels of the dataset ( |
methods.names |
The name of the compared methods ( |
positive |
The label of the positive class. Defaults to the first level of |
type |
|
... |
Other parameters, passed to the underlying plot. |
A ROC curve needs a score: the higher it is, the more likely the observation is to
belong to the positive class. The natural one is the estimated probability returned by
predict (model, x, fuzzy = TRUE). Hard class labels give only two distinct values,
so the "curve" reduces to three points and the area under it says very little. That coarse
version is available on purpose – it makes a useful comparison – but it has to be asked
for: pass hard labels, or type = "hard".
Nothing; the curves are drawn on the current graphics device.
cost.curves, performance
require (datasets)
data (iris)
d = iris
levels (d [, 5]) = c ("+", "+", "-") # Building a two classes dataset
model.nb = NB (d [, -5], d [, 5])
model.lda = LDA (d [, -5], d [, 5])
# From the estimated probabilities: the meaningful curve
roc.curves (predict (model.nb, d [, -5], fuzzy = TRUE), d [, 5], positive = "+")
# Two models compared, one score column each
roc.curves (cbind (NB = predict (model.nb, d [, -5], fuzzy = TRUE) [, "+"],
LDA = predict (model.lda, d [, -5], fuzzy = TRUE) [, "+"]),
d [, 5], c ("NB", "LDA"), positive = "+")
# The same predictions reduced to hard labels: three points, and little to read
roc.curves (predict (model.nb, d [, -5]), d [, 5], positive = "+", type = "hard")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.