roc: Receiver Operating Characteristic and Precision-Recall Curves

Description Usage Arguments Details Value References See Also Examples

Description

Computes the Receiver Operating Characteristic (ROC) or precision-recall curves from contingencies tables (confusion matrices) and their associated probabilities, and optionally plots them.

Usage

1
2
roc( contabs, plotit = TRUE)
prc( contabs, plotit = TRUE, ymax = max(y))

Arguments

contabs

A data frame representing a contingency tables (confusion matrices) for a binary classification experiment. The column names should include TP (for true positive), FN (for false negative), FP (for false positive), TN (for true negative); these can be given in any order.

plotit

A logical variable indicating whether or not the ROC curve should be plotted.

ymax

Upper vertical axis value for plotting precision-recall curves with prc. The default is max(y), (the maximum value for precision derived from the contingency table). ymax should be no larger than 1.

Details

The estimated area may be inaccurate when the sector covered by the contingency tables is small, and should be used with caution in such cases.

Value

A vector with the following named components:

area

The area under the extended curve (covered by the black solid and dotted lines).

sector

The estimated area under the sector (below the curve and within the red lines) covered by the contingency table.

width

The width of the sector (within the red vertical lines) covered by the contingency table.

As a side-effect, the ROC (roc) or precision-recall curve (prc) is plotted if plotit = TRUE. The red vertical lines highlight the sector covered by the contingency table. The black lines approximate the curve. They are dotted beyond the endpoints of the sector, where there is no information from the contingency table. The diagonal blue line in the ROC curve indicates the line between (0,0) and (1,1).

References

J. Davis and M. Goadrich, The relationship between Precision-Recall and ROC curves, manuscript, Department of Computer Science, University of Wisconsin.

See Also

contabs

Examples

 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
data(dream4)

network <- 1

nTimePoints <- length(unique(dream4ts10[[network]]$time))

edges1ts10 <- networkBMA( data = dream4ts10[[network]][,-(1:2)],
                      nTimePoints = nTimePoints, prior.prob = 0.1)

# check for self loops in estimated network
selfN <- any(as.character(edges1ts10[,1]) == as.character(edges1ts10[,2]))
selfN

reference <- dream4gold10[[network]]

# check for self loops in reference (there are none)
selfR <- any(as.character(reference[,1]) == as.character(reference[,2]))
selfR

# restrict reference to edges; first two columns (gene) only
reference <- reference[reference[,3] == 1,1:2]

contingencyTables <- contabs(network = edges1ts10, reference = reference,
                             size = 100)

roc(contingencyTables)
prc(contingencyTables)

networkBMA documentation built on Jan. 28, 2021, 2:02 a.m.