How to calculate recall and Precision
Show older comments
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
Wided HAMMEDI
on 15 Jul 2017
Edited: Wided HAMMEDI
on 15 Jul 2017
%%% 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));
Panashe Chisasa
on 2 Jun 2020
thank you so much for this. It helped me with my final year project.
BANDARU UMAMADHURI
on 21 Oct 2020
what does label mean here ??
OYENIRAN OLUWASHINA
on 26 Feb 2021
Thank you so much for the snippet, it really aid my work. Is there any way to calculate recall and precision for each class?
Answers (0)
Categories
Find more on Creating and Concatenating Matrices 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!