Main Content

roc

Receiver operating characteristic

Description

[tpr,fpr,thresholds] = roc(targets,outputs) takes a matrix of targets and a matrix of outputs, and returns the true-positive/positive ratios, the false-positive/negative ratios and the thresholds over interval [0,1].

Tip

roc does not support categorical targets. To compute ROC metrics for categorical targets, use rocmetrics.

For a single class problem, the function takes a matrix of boolean values indicating class membership and a matrix of outputs values in the range [0,1].

The receiver operating characteristic is a metric used to check the quality of classifiers. For each class of a classifier, roc applies threshold values across the interval [0,1] to outputs. For each threshold, two values are calculated, the True Positive Ratio (TPR) and the False Positive Ratio (FPR). For a particular class i, TPR is the number of outputs whose actual and predicted class is class i, divided by the number of outputs whose predicted class is class i. FPR is the number of outputs whose actual class is not class i, but predicted class is class i, divided by the number of outputs whose predicted class is not class i.

You can visualize the results of this function with plotroc.

example

Examples

collapse all

This example shows how to calculate and plot the ROC of a network trained to recognize Iris flowers.

load iris_dataset
net = patternnet(20);
net = train(net,irisInputs,irisTargets);
irisOutputs = sim(net,irisInputs);
[tpr,fpr,thresholds] = roc(irisTargets,irisOutputs)

Input Arguments

collapse all

Targets, specified as an S-by-Q matrix, where each column vector contains a single 1 value, with all other elements 0. The index of the 1 indicates which of S categories that vector represents.

For a single class problem, this argument is specified as a 1-by-Q matrix of boolean values indicating class membership.

Outputs, specified as an S-by-Q matrix, where each column contains values in the range [0,1]. The index of the largest element in the column indicates which of S categories that vector presents. Alternately, 1-by-Q vector, where values greater than or equal to 0.5 indicate class membership, and values below 0.5, nonmembership.

Output Arguments

collapse all

Proportion of the targets that are greater than or equal to the threshold that actually have a target value of 1, returned as a 1-by-S cell array of 1-by-N vectors.

For a single class problem, this output argument is returned as a 1-by-N vector.

Proportion of the targets that are greater than or equal to the threshold that actually have a target value of zero, returned as a 1-by-S cell array of 1-by-N vectors.

For a single class problem, this output argument is returned as a 1-by-N vector.

Thresholds, returned as a 1-by-S cell array of 1-by-N vectors over interval [0,1].

For a single class problem, this output argument is returned as a 1-by-N vector.

Version History

Introduced in R2008a

See Also

|