File Exchange

image thumbnail

Precision, Specificity, Sensitivity, Accuracy & F1-score

version 1.0.0 (2.32 KB) by Eugenio Bertolini
Given a confusion matrix as input, this function calculates the main statistics of interest, including macro AVG and microAVG.

5 Downloads

Updated 22 Jan 2021

View License

Given a confusion matrix as input, this function calculates the main statistics of interest (including macro AVG and microAVG):
'name' 'classes' 'macroAVG' 'microAVG'
Precision / / / x o
Specificity / / / x o
Sensitivity / / / x o
Accuracy / / / x o
F1-score / / / x o

Cite As

Eugenio Bertolini (2021). Precision, Specificity, Sensitivity, Accuracy & F1-score (https://www.mathworks.com/matlabcentral/fileexchange/86158-precision-specificity-sensitivity-accuracy-f1-score), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Prashant Pandey

I believe that your function has mixed up false positives and false negatives in the confusion matrix output by confusionmat(). See for example the output by built-in functions plotconfusion() and confusionchart().
One simple fix would be to do:
confusion=confusion' ;
at the beginning of statsOfMeasure()

Andrea Loddo

Excellent tool. Great work!

MATLAB Release Compatibility
Created with R2020b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!