Accuracy Calculator
Calculate accuracy, precision, recall, F1 score, MCC, and Cohen's Kappa from a confusion matrix. Full classification metrics instantly.
About
Classification errors propagate silently. A model reporting 95% accuracy on an imbalanced dataset where 95% of samples belong to one class is no better than a constant predictor. Relying on accuracy alone masks critical failure modes: missed fraud transactions, undetected tumors, ignored intrusions. This tool computes the full diagnostic profile from a 2Γ2 confusion matrix - accuracy, precision, recall, F1 score, Matthews Correlation Coefficient (MCC), Cohenβs ΞΊ, balanced accuracy, and Youdenβs J. Each metric exposes a different dimension of classifier performance.
The tool assumes a binary classification context with known ground-truth labels. Results are exact given integer counts. For multi-class problems, apply one-vs-rest decomposition externally and enter each binary sub-problem here. Note: MCC is undefined when any row or column of the confusion matrix sums to zero. The calculator flags such edge cases explicitly rather than returning misleading values.
Formulas
All metrics derive from a 2Γ2 confusion matrix with counts TP, TN, FP, FN. Total sample size N = TP + TN + FP + FN.
MCC is undefined when any factor in the denominator is zero. The calculator returns NaN in that case.
Where po = observed agreement (accuracy), and pe = expected agreement by chance = (TP+FP)(TP+FN) + (TN+FN)(TN+FP)N2.
Variable legend: TP = True Positives (correctly predicted positive). TN = True Negatives (correctly predicted negative). FP = False Positives (Type I error). FN = False Negatives (Type II error). N = total sample count. PPV = Positive Predictive Value (Precision). TPR = True Positive Rate (Recall / Sensitivity). TNR = True Negative Rate (Specificity). FPR = False Positive Rate = 1 β TNR. FNR = False Negative Rate = 1 β TPR.
Reference Data
| Metric | Formula | Range | Best Value | Use When |
|---|---|---|---|---|
| Accuracy | (TP + TN) Γ· N | 0 - 1 | 1 | Balanced classes |
| Precision (PPV) | TP Γ· (TP + FP) | 0 - 1 | 1 | Cost of false alarms is high |
| Recall (Sensitivity / TPR) | TP Γ· (TP + FN) | 0 - 1 | 1 | Missing positives is costly |
| Specificity (TNR) | TN Γ· (TN + FP) | 0 - 1 | 1 | Negative class matters |
| F1 Score | 2 β P β RP + R | 0 - 1 | 1 | Imbalanced datasets |
| MCC | See Formulas section | β1 - 1 | 1 | Gold standard for binary |
| Cohenβs Kappa (ΞΊ) | See Formulas section | β1 - 1 | 1 | Agreement beyond chance |
| Balanced Accuracy | (TPR + TNR) Γ· 2 | 0 - 1 | 1 | Imbalanced classes |
| Youdenβs J | TPR + TNR β 1 | β1 - 1 | 1 | Optimal threshold selection |
| Prevalence | (TP + FN) Γ· N | 0 - 1 | - | Dataset composition check |
| Negative Predictive Value | TN Γ· (TN + FN) | 0 - 1 | 1 | Trust in negative predictions |
| False Discovery Rate | FP Γ· (FP + TP) | 0 - 1 | 0 | Complement of Precision |
| False Omission Rate | FN Γ· (FN + TN) | 0 - 1 | 0 | Missed positive rate among negatives |
| Positive Likelihood Ratio | TPR Γ· FPR | 0 - β | β | Diagnostic utility |
| Negative Likelihood Ratio | FNR Γ· TNR | 0 - β | 0 | Rule-out power |
| Diagnostic Odds Ratio | LR+ Γ· LRβ | 0 - β | β | Single discriminative power metric |