Description Usage Arguments Value References See Also Examples

This function returns the ROC curve and computes the area under the curve (AUC) for binary classifiers.

1 2 |

`response` |
A vector of responses containing two classes to be used to compute the ROC curve. It can be of class |

`predicted` |
A vector containing a prediction for each observation. This can be of class |

`plotit` |
Logical, if |

`add.roc` |
Logical, if |

`n.thresholds` |
Number of |

`...` |
Further arguments to be passed either to |

The value is an object of class `roc.curve`

which has components

`Call` |
The matched call. |

`auc` |
The value of the area under the ROC curve. |

`false positive rate` |
The false positive rate (or equivalently the complement of sensitivity) of the classifier at the evaluated |

`true positive rate` |
The true positive rate (or equivalently the specificity) of the classifier at the evaluated |

`thresholds` |
Thresholds at which the ROC curve is evaluated. |

Fawcet T. (2006). An introduction to ROC analysis. *Pattern Recognition Letters*, 27 (8), 861–875.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ```
# 2-dimensional example
# loading data
data(hacide)
# check imbalance on training set
table(hacide.train$cls)
# model estimation using logistic regression
fit.hacide <- glm(cls~., data=hacide.train, family="binomial")
# prediction on training set
pred.hacide.train <- predict(fit.hacide, newdata=hacide.train)
# plot the ROC curve (training set)
roc.curve(hacide.train$cls, pred.hacide.train,
main="ROC curve \n (Half circle depleted data)")
# check imbalance on test set
table(hacide.test$cls)
# prediction using test set
pred.hacide.test <- predict(fit.hacide, newdata=hacide.test)
# add the ROC curve (test set)
roc.curve(hacide.test$cls, pred.hacide.test, add=TRUE, col=2,
lwd=2, lty=2)
legend("topleft", c("Resubstitution estimate", "Holdout estimate"),
col=1:2, lty=1:2, lwd=2)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.