pROC 1.10.0
A new update of pROC is now available on CRAN: version 1.10.0.
ggplot2 support (Experimental)
A new function was introduced: ggroc
. Given a roc
object, or a (optionally named) list
of roc
objects, it returns a ggplot object, that can then be printed, with optional aesthetics, themes etc. Here is a basic example:
library(pROC) # Create a basic roc object data(aSAH) rocobj <- roc(aSAH$outcome, aSAH$s100b) rocobj2 <- roc(aSAH$outcome, aSAH$wfns) library(ggplot2) # Multiple curves: gg2 <- ggroc(list(s100b=rocobj, wfns=rocobj2)) gg2
Basic ggplot with two ROC curves.
The usual ggplot syntax applies, so you can add themes, labels, etc. Note the aes
argument, which control the aesthetics for geom_line to map to the different ROC curves supplied. Here we use "linetype"
instead of the default color:
# with additional aesthetics: gg2b <- ggroc(list(s100b=rocobj, wfns=rocobj2), aes="linetype", color="red") # You can then your own theme, etc. gg2b + theme_minimal() + ggtitle("My ROC curve")
Basic ggplot with two ROC curves.
This functionality is currently experimental and subject to change. Please report bugs and feedback on pROC's GitHub issue tracker.
Precision and recall in coords
The coords
function supports two new ret
values: "precision"
and "recall"
:
library(pROC) # Create a basic roc object data(aSAH) rocobj <- roc(aSAH$outcome, aSAH$s100b) coords(rocobj, "best", ret = c("threshold", "sensitivity", "specificity", "precision", "recall")) threshold sensitivity specificity precision recall 0.2050000 0.6341463 0.8055556 0.6500000 0.6341463
It makes it very easy to get a Precision-Recall (PR) plot:
plot(precision ~ recall, t(coords(rocobj, "all", ret = c("recall", "precision"))), type="l", main = "PR plot of S100B")
A simple PR plot.
Automated testing
Several functions are now covered with tests (powered by the testthat package) to ensure correct behavior. This allowed me to find and fix a few glitches. It will also make it easier to refactor code in the future.
The tests are automatically run by R CMD check
. Additional tests that are too slow to be enabled by defauld can be activated with the RUN_SLOW_TESTS
environment variable.
export RUN_SLOW_TESTS=true R CMD check pROC
Test results can be seen on Travis CI, and the coverage of the tests can be seen on Codecov. Currently 30% of the code is tested. This includes most functionality, with the exception of bootstrapping and smoothing which I plan to implement in the future.
Obtaining the update
To update your installation, simply type:
install.packages("pROC")
Here is the full changelog:
- Basic ggplot2 support (one and multiple ROC curves)
- Implement
precision
andrecall
forcoords
- Fix: properly handle NAs in cases when passing cases/controls to
roc
(thanks Thomas König for the report) - Fix various minor bugs detected with new unit tests
Xavier Robin
Published Sunday, June 11, 2017 08:03 CEST
Permalink: /blog/2017/06/11/proc-1.10.0
Tags:
pROC
Comments: 0
Comments
No comment