The results of Plot ROC is strange
Show older comments
can someone correct my code. I tried to draw ROC but when I run it, the plot is not normal as usual. this is the code
data = [170 66 ; 160 50 ; 170 63 ; 173 61 ; 168 58 ; 184 88 ; 189 94 ; 185 88 ]
labels=[0;0;0;0;0;1;1;1];
opts = '-s 0 -t 2 -c 32 -g 1'; %# libsvm training options
nfold=5;
indices = crossvalind('Kfold', labels, nfold);
cp=classperf(labels)
acc = zeros(nfold,1);
for i=1:nfold
testIdx = (indices == i); trainIdx = ~testIdx;
trainLabel = labels(trainIdx);
trainData = data(trainIdx,:);
testData=data(testIdx,:);
testLabel=labels(testIdx);
model = svmtrain(trainLabel, trainData, opts);
[predTestLabel, acc, decVals] = svmpredict(testLabel, testData, model);
acc = mean(predTestLabel == testLabel);
cmTest = confusionmat(testLabel,predTestLabel)
cp=classperf(cp,predTestLabel,testIdx);
end
a=cp.CountingMatrix
result_accuracy=mean(akurasi)
% plot(1-specificity,sensitivity)
[FPR, TPR, Thr, AUC, OPTROCPT] = perfcurve(testLabel,decVals(:,1),1);
figure
plot(FPR, TPR, 'or-')
xlabel('FP rate (FPR, 1-Specificity)'); ylabel('TP rate (TPR, Sensitivity)')
title('ROC for classification')
grid on;
Iam still confused how to put the variabel in this
[FPR, TPR, Thr, AUC, OPTROCPT] = perfcurve(testLabel,decVals(:,1),1);
does someone have any idea how to solve this ??? thank you
1 Comment
nur zawatil isqi
on 26 Feb 2014
Have u find the solution? Why you don't use plotroc? its' seem simpler.
Answers (0)
Categories
Find more on Discriminant Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!