matlab - Calculate precision and recall on WANG database -
i have made cbir system in matlab , have used similarity measurement euclidean distance. using each query image retrieve top 20 images.
i have used wang dataset testing system.
contains 10 classes(like african people, buses, roses etc.) each containing 100 images.(1000 images in total).
my method:
1. using correlogram, co-occurence matrix(ccm) , difference between pixel scan pattern(dbpsp) constructing vector(64+196+28=288 dimensions respectively).
- each of 1000 db image have vector constructed beforehand.
- now query image comes , construct it's vector too(228 dimensions again).
- i use euclidean distance similarity , sort db image vectors in descending order of euclid distance.
top 20 results shown.
in 20 can have tp or fp.
for single query image can calculate precision , recall , plot pr-curve using link.
how can same whole class?
my approach: each image belonging class find top 20 images , it's respective tp(true positives) , fp (false positive).
tp fp image1 17 3 image2 15 5 ... ... image100 10 10 total 1500 500
precision of class =1500/(2000) = .75 (is right??)
recall of class ---> stuck ??
pr-curve ----> stuck ?? links said need classifier , not... confused.
so noted, can calculate precision follows.
p = tp ./ ( tp + fp );
however, need have either have fn or number of total falses calculate recall. discussed in chat, need find way determine fn , fp data. can use following formula calculate recall.
r = tp ./ ( tp + fn )
if have confusion matrix or data, can use custom confusionmat2f1.m calculate precision, recall, , f1 score. assumes confusion matrix formatted how matlab defines it. explanation of each line inline. please let me know if want more clarification.
function [f,p,r] = confusionmat2f1( c ) %% confusionmat2f1( c ) % % inputs % c - confusion matrix % % outputs % f - f1 score column vector % p - precision column vector % r - recall column vector %% % confusion matrix probability m = sum( c, 3 ); % calculate precision p = diag(m) ./ sum(m,1)'; % calculate recall r = diag(m) ./ sum(m,2); % calculate f1 score f = f1( p, r );