The mathematical foundation of confusion matrix analysis provides the rigorous framework for quantitative evaluation of classification performance across various domains.
Core Metric Formulations:
Accuracy = (TP + TN) / (TP + FP + TN + FN) measures overall correctness as the proportion of correct predictions among total predictions.
Precision = TP / (TP + FP) quantifies the proportion of positive predictions that were actually correct, answering "Of all positive predictions, how many were right?"
Recall (Sensitivity) = TP / (TP + FN) measures the proportion of actual positive cases correctly identified, answering "Of all actual positives, how many did we find?"
Specificity = TN / (TN + FP) quantifies the proportion of actual negative cases correctly identified, complementing sensitivity for complete evaluation.
F1-Score = 2 × (Precision × Recall) / (Precision + Recall) provides the harmonic mean of precision and recall, giving equal weight to both metrics.
Advanced Metrics and Extensions:
Matthews Correlation Coefficient (MCC) = (TP×TN - FP×FN) / √[(TP+FP)(TP+FN)(TN+FP)(TN+FN)] provides a balanced measure even for imbalanced datasets.
Balanced Accuracy = (Sensitivity + Specificity) / 2 adjusts accuracy for imbalanced datasets by averaging the accuracies of each class.
For multi-class problems, confusion matrices extend to n×n tables, with metrics calculated using one-vs-all or one-vs-one approaches for each class individually.