How to find accuracy of a classification algorithm
Show older comments
How do I find the algorithm of my BLOB classification algorithm? I have extracted all the information and have found the positive BLOBs and the negative. I have the ground positives and negative.
I understand that to find the accuracy I need to know the true positives etc, but how do I calculate them?
Im = [0 1 1 0 0 0 0 0 0 0;
0 1 1 0 1 1 0 0 0 1;
0 1 1 0 1 1 0 1 0 1;
0 0 0 0 0 0 0 1 0 1;
0 1 1 1 0 1 1 1 0 1;
0 0 0 0 0 0 1 1 0 1;
0 1 0 0 0 0 0 0 0 1;
0 1 0 0 0 0 1 1 0 0;
0 0 0 0 0 0 1 0 0 0;
0 0 0 0 0 0 0 0 0 0];
bw = bwlabel(Im,4);
blob = regionprops(bw, 'All');
% These are the blob indexes for the BLOBs
GN = [2 5 7]; % Ground Negative
GP = [1 3 4 6 ] % Ground Positive
all = [blob(:).Area];
Positive = find(all < 5 )
Negative = find(all > 5 )
% N = TN + TP + FP + FN
% Acc = (TP + TN)/N
Accepted Answer
More Answers (1)
Image Analyst
on 20 Nov 2021
0 votes
Hmmmm...lots of problem with your code. First of all, you have no reliable ground truth. It's very dangerous to just assume a blob is true or false based on its label. The labels can change from image to image. Even if the image is the same but just very slightly rotated or has a slight amount of noise, the label number could change. So you can't use label numbers as an indicator of whether a blob is true or not.
You'll have to come up with a ground truth IMAGE. Then you can use dice() to compute the similarity coefficient. Or you can use imreconstruct() to determine what blobs you found in your test image with your algorithm being tested, are in, or missing, from your ground truth image. Then you can compute true and false positives and negatives. Then, assuming you want to build up the ROC curve you're going to have to
- change either the algorithm (and use the same image) or
- change images (but use the same algorithm).
For #2 you're going to have to have a ground truth image for each input image of course.
Categories
Find more on Detection 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!