MATLAB: Plotting ROC curve from confusion matrix

aucclassificationDeep Learning Toolboximage processingknnrocStatistics and Machine Learning Toolbox

I have used knn to classify 86 images into 2 classes. I have found the confusion matrix and accuracy using matlab commands confusionmat and classperf. How do I find the ROC curve? I know it is a ratio of true positive rate and false positive rate at all possible thresholds, but how do I calculate it when I only have confusion matrix to play with? I have banged my head for weeks over theory of ROC but still am no where close to actually plotting it. Please if someone could guide me with respect to plotting it on matlab and not the theory behind it, that would be great.

Best Answer

It is challenging but not impossible. The main idea is to get more confusion matrices, hence points on the ROC curve. If you had scores associated with each image, you could use directly the perfcurve function https://www.mathworks.com/help/stats/perfcurve.html
So the challenge is to assign scores to your 86 images, each of which would tell how close the image is to the true class. Some classifiers return that score, but not K-NN as far as I understand it. Here is one suggestion how you can decide those scores, but you can come up with your own method. http://stackoverflow.com/questions/13642390/knn-classification-in-matlab-confusion-matrix-and-roc?rq=1
Related Question