How to calculate recall and Precision

Hi,
I've a data set of 101 records with 21 classes. First of all I want to generate separately 21 confusion matrix for those 21 classes and then want to calculate recall and precision for this data. Please guide me that how can I write a do it in Matlab.
Thank you.

4 Comments

%%% matrice de confusion
[confMat,order] = confusionmat(LABEL,target_test);
%%% calcul de la précision , le rappel (recall) et le F-score
%%% recall
for i =1:size(confMat,1)
recall(i)=confMat(i,i)/sum(confMat(i,:));
end
recall(isnan(recall))=[];
*
Recall*=sum(recall)/size(confMat,1);
%%% précision
for i =1:size(confMat,1)
precision(i)=confMat(i,i)/sum(confMat(:,i));
end
Precision=sum(precision)/size(confMat,1);
%%% F-score
F_score=2*Recall*Precision/(Precision+Recall); %%F_score=2*1/((1/Precision)+(1/Recall));
thank you so much for this. It helped me with my final year project.
what does label mean here ??
Thank you so much for the snippet, it really aid my work. Is there any way to calculate recall and precision for each class?

Sign in to comment.

Answers (0)

Categories

Asked:

on 29 Dec 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!