I'm trying to find the True negative in a confusion matrix, I have computed successfully from scratch the precision and recall/sensibility, now i need to compute the accuracy and specificity.
This is my confusion Matrix:
Computing the precision for 0 class
Precision= TP*100/(TP+FP)
precision = 66*100/(66+2+0)
precision = 97.0588
Computing the precision for 1 class
Precision= TP*100/(TP+FP)
precision = 81*100/(81+1+1)
precision = 97.5903
Computing the precision for 2 class
Precision= TP*100/(TP+FP)
precision = 56*100/(56+3+0)
precision = 94.9152
Using the Pycm library I got:
PPV(Precision or positive predictive value) 0.97059 0.9759 0.94915
where 0.97059 is the precision for the class 0, and the next for 1 and the last for the 2 class.
Computing the recall for 0 class
recall = TP*100/(TP+FN)
recall = 66/(66+2+0)
recall = 97.0588
Computing the recall for 1 class
recall = TP*100/(TP+FN)
recall = 81/(81+2+3)
recall = 94.1860
Computing the recall for 2 class
recall = TP*100/(TP+FN)
recall = 56/(56+0+1)
recall = 94.1860
Using Pycm library I got:
TPR(recall or true positive rate) 0.98507 0.94186 0.98246
where 0.98507 is the precision for the class 0, and the next for 1 and the last for the 2 class.
What happen now if I want to compute the accuracy? equation: Accuracy = (TP+TN)*100/(TP+TN+FP+FN) the equation is ok? I'm using the constant 100 to get the percent and not 0.x or 0.00xx but 90.x etc.
I would like to know how I can get the True Negatives (TN) to compute the accuracy and specificity, currently using Pycm library I'm getting this values for the 3 classes:
ACC(Accuracy) 0.98571 0.96667 0.98095
Best Answer
I'm one of the PyCM developers.
precision
calculation method is completely correct.recall
calculation you should consider improperly classified items in each row :class 0 :
class 1 :
class 2 :
You should consider
class
vsother
and add up items that classified correctly asother
, in other words eliminate row and col related toclass
and add up remaining.class 0 :
class 1 :
class 2 :
Best Regards
Sepand Haghighi