MATLAB: Sensitivity ,Specificity and Accuracy calculation from Confusion matrix

confusion matrixDeep Learning Toolboxneural networkpatternet

I calculate correct accuracy classification from confusion matrix as 1-c ,Sensiticity TP/(TP+FN) as SE = cm(2,2)/sum(cm(2,:)) and Specificity TN/(TN+FP) SP=cm(1,1)/sum(cm(1,:)) to a binary classification problem .Are these calculations right ?I use 10 fold cross validation in my data and i want calculate CA,SE ,SP of the test set which incudes 2 samples each time.Sometimes in test all are positives and classified as positives and then specificity is NaN .How can i cope this ?Im interested for the mean of these in 10 folds .

Best Answer

Dear Lea, Whether you work on Image or Numerical data sets, If you have numerical datasets and already built confusion matrix then you can easily able to compute the above parameters. Please follow the following link- http://www.dataschool.io/simple-guide-to-confusion-matrix-terminology/
Thanks, if you need more clarification, let me know here.