Create an ROC Curve From Binary Classification Data

조회 수: 4 (최근 30일)
Tim
Tim 2013년 1월 29일
I'm trying to plot an ROC curve and get the area under the curve. I have a vector PREDICTIONS with the binary prediction, and the vector TRUE with the true values. A positive is 1, and negative is -1.
I tried to call the function like this:
[X,Y] = perfcurve(PREDICTIONS,TRUE,[1 -1]);
But got this error:
[X,Y] = perfcurve(labels,scores,[1 -1]); ??? Error using ==> perfcurve at 368 Less than two classes are found in the array of true class labels.
Can anybody help me out with this?

채택된 답변

Ilya
Ilya 2013년 1월 30일
From perfcurve doc:
[X,Y] = perfcurve(labels,scores,posclass) computes a ROC curve for a vector of classifier predictions scores given true class labels, labels. labels can be a numeric vector, logical vector, character matrix, cell array of strings or categorical vector. scores is a numeric vector of scores returned by a classifier for some data. posclass is the positive class label (scalar), either numeric (for numeric labels), logical (for logical labels), or char.
So the 1st input must be the true class labels, not predictions. labels is a vector with N elements for N observations. The 2nd input, scores, must be a numeric vector of classification scores. I don't know what you mean by "binary prediction", but if you pass a vector of scores filled with +1 and -1, perfcurve won't be able to compute a curve. The 3rd input, posclass, must be scalar, not a vector with 2 elements.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 ROC - AUC에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by