confusionmatStats(g​roup,grouphat)

This function evaluates the common performance measures for classification models.
4.6K Downloads
Updated 12 Oct 2015

View License

function stats = confusionmatStats(group,grouphat)
% INPUT
% group = true class labels
% grouphat = predicted class labels
%
% OR INPUT
% stats = confusionmatStats(group);
% group = confusion matrix from matlab function (confusionmat)
%
% OUTPUT
% stats is a structure array
% stats.confusionMat
% Predicted Classes
% p' n'
% ___|_____|_____|
% Actual p | | |
% Classes n | | |
%
% stats.accuracy = (TP + TN)/(TP + FP + FN + TN) ; the average accuracy is returned
% stats.precision = TP / (TP + FP) % for each class label
% stats.sensitivity = TP / (TP + FN) % for each class label
% stats.specificity = TN / (FP + TN) % for each class label
% stats.recall = sensitivity % for each class label
% stats.F-score = 2*TP /(2*TP + FP + FN) % for each class label
%
% TP: true positive, TN: true negative,
% FP: false positive, FN: false negative
%

Cite As

Audrey Cheong (2024). confusionmatStats(group,grouphat) (https://www.mathworks.com/matlabcentral/fileexchange/46035-confusionmatstats-group-grouphat), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
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!
Version Published Release Notes
1.3.0.0

Accuracy formula corrected. Added group/class label order.
Bug fix (F-score to Fscore)

1.2.0.0

function title

1.1.0.0

Added two comments

1.0.0.0