MATLAB-based ROC Curves

来源:互联网 发布:sql设置默认值为0 编辑:程序博客网 时间:2024/04/29 19:19

DETAILS ABOUT ROC (RECEIVER OPERATING CHARACTERISTIC) CURVES CAN BE REFEREED FROMHERE (CHINESE). HOWEVER, NEW VERSION MATLAB SOFTWARE PROVIDES ROC API AS FOLLOWS.


>> help roc

roc Receiver operating characteristic.

The receiver operating characteristic is a metric used to check the quality of classifiers. For each class of a classifier, threshold values across the interval [0,1] are applied to outputs. For each threshold, two values are calculated, the True Positive Ratio (the number of outputs greater or equal to the threshold, divided by the number of one targets), and the False Positive Ratio (the number of outputs greater then the threshold, divided by the number of zero targets).

For single class problems, [TPR,FPR,TH] = roc(T,Y) takes a 1xQ target matrix T, where each element is either 1 or 0 indicating class membership or non-menbership respectively, and 1xQ outputs Y of values in the range [0,1].

It returns three 1xQ vectors: the true-positive/positive ratios TPR, the false-positive/negative ratios FPR, and the thresholds associated with each of those values TH.

For multi-class problems [TPR,FPR,TH] = roc(T,Y) takes an SxQ target matrix T, where each column contains a single 1 value, with all other elements 0. The row index of each 1 indicates which of S categories that vector represents. It also takes an SxQ output matrix Y, with values in the range [0,1]. The row indices of the largest elements in each column of Y indicate the most likely class.

In the multi-class case, all three values returned are 1xS cell arrays, so that TPR{i}, FPR{i} and TH{i} are the ratios and thresholds for the ith class.

roc(T,Y) can also take a boolean row vector T, and row vector Y, in which case two categories are represented by targets 1 and 0.

Here a network is trained to recognize iris flowers the roc is calculated and plotted.

[x,t] = iris_dataset;
net = patternnet(10);
net = train(net,x,t);
y = net(x);
[tpr,fpr,th] = roc(t,y)
plotroc(t,y)

See also plotroc, confusion

Reference page in Help browser
doc roc



0 0
原创粉丝点击