precision and recall of two matrices

2 views (last 30 days)
I have two binary matrices 701x701 each. One represents what i got from my algorithm and the other is the groundtruth of the dataset i'm using. In each column i have a 1 if the photo is considered near duplicate, if not is a 0, in each row i have a different photo. Both matrix have the diagonal composed by ones. (The dataset is composed by 701 photos.) I have to calculate recall and precision. The problem is that i don't know wich one is false positive, true positive, false negative or true negative. How can i do it?

Accepted Answer

Michael Abboud
Michael Abboud on 28 Aug 2017
For a typical classification problem where each input image receives a single label you can use the 'confusion' function to calculate these statistics:
However, it sounds like you have a special case where each input image gives a full output of length 701 where any number of them can be 0s or 1s. My guess is that the above function was not designed for this use, and it may even be that the statistics you mention are not well defined for the type of problem you have described above.
I would recommend that you look at the Wikipedia page on Confusion Matrices, which nicely explains the various statistics:
It may be possible to simply convert each matrix into a long vector of 1s and 0s and from here calculate precision and recall according to the formulas, however I'm not fully convinced this would be the correct approach as it discards a vast amount of semantic meaning and may only serve to provide some ballpark statistics

More Answers (0)


Find more on Mathematics and Optimization 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!