Gwenji
Gwenji

Reputation: 117

What are the MATLAB 'perfcurve' Roc Curve Parameters?

I have been using the LibSVM classifier to classify between 3 different classes - labeled 2, 1, -1

I'm trying to use MATLAB to generate Roc Curve graphs for some data produced using LibSVM but am having trouble understanding the parameters it needs to run.

I assume that:

labels is the vector of labels generated that states into which class my data belongs (mine consists on 1, -1 and 2 and is 60x1 in size)

scores is the variable created by LibSVM called 'accuracy_score' (60x3 in size)

But I don't know what posclass is?

I would also appreciate finding out if my assumptions are correct, and if not, why not?

Upvotes: 3

Views: 8561

Answers (2)

Eleonora Ciceri
Eleonora Ciceri

Reputation: 1798

See here for a clear explanation:

Given the following instruction: [X,Y] = perfcurve(labels,scores,posclass); labels are the true labels of the data, scores are the output scores from your classifier (before the threshold) and posclass is the positive class in your labels.

Upvotes: 4

Cici
Cici

Reputation: 1447

see documentation of percurve, posclass is the label of positive class, in your case it has to be either 1,-1 or 2 http://www.mathworks.com/help/stats/perfcurve.html

ROC curve have "false positive rate" on x axis and "true positive rate on y axis". By specifying the posclass, you are specifying with respect to which class you are calculating false positive rate and true positive rate. e.g. if you specify posclass as 2, you consider that when the true label is 2, predicting either 1 or -1 is considered a false prediction (false negative).

Edit: The accuaracy_score you metioned (in my version of the documentation(3.17, in matlab folder), it is called decision_values/prob_estimates) have 3 column, each column correspond to the probability of the data belonging to one class.

e.g.

model=svmtrain(train_label,train_data);
[predicted_label, accuracy, decision_values]=predict(test_label,test_dat,model);

model.Label contains the class labels, individual columns in decision_values contains probability of the the test case belong to class specified in model.Label.(see http://www.csie.ntu.edu.tw/~b91082/SVM/README).

to use purfcurve to compute ROC for class m:

[X,Y] = perfcurve(truelabels, decision_values(:,m)*model.Label(m),model.Label(m));

It is essential to do decision_values(:,m)*model.Label(m) especially when you class label is a negative number.

Upvotes: 3

Related Questions