Your classifier is right 85% of the time. Is that good? On its own the number says little. A confusion matrix splits the predictions into four kinds: true positives, false positives, false negatives and true negatives. Each common score asks a different question of those four numbers. Precision asks how often a “yes” is right. Recall asks how many of the real cases were found. F1 balances the two.
Enter the four counts for a binary model and every standard metric appears, each with the working that produced it. Or paste the actual and predicted labels, for any number of classes. The tool then builds the matrix itself and prints a report like scikit-learn's classification_report, with precision, recall, F1 and support for every class plus macro, weighted and micro averages.
Worked Example: 45 Hits, 5 False Alarms
The page opens with TP 45, FP 5, FN 10 and TN 40, 100 cases in all.
- Accuracy (45 + 40) ÷ 100 = 85.00%. Precision 45 ÷ 50 = 90.00%. Recall 45 ÷ 55 = 81.82%.
- F1 = 2 × 45 ÷ (90 + 5 + 10) = 85.71%. It sits between precision and recall but nearer the lower one, which is the point of a harmonic mean.
- Specificity 40 ÷ 45 = 88.89%, balanced accuracy 85.35%, and the Matthews correlation coefficient 0.7035.
- Switch to Actual vs predicted labels (or press Load Sample once) for 12 cat, dog and bird labels. The matrix shows 9 of 12 correct (75.00%), with per-class F1 of 0.667 for bird, 0.800 for cat and 0.750 for dog, and a macro F1 of 0.739.
The Formulas, Each With Its Own Denominator
- Precision = TP ÷ (TP + FP), over everything the model called positive. Recall = TP ÷ (TP + FN), over everything that really was positive.
- F1 = 2·TP ÷ (2·TP + FP + FN), the same value as 2PR ÷ (P + R). Specificity = TN ÷ (TN + FP) is recall for the negative class.
- MCC = (TP·TN − FP·FN) ÷ √((TP+FP)(TP+FN)(TN+FP)(TN+FN)). It runs from −1 to 1 and stays honest on imbalanced data.
- For several classes, each class is scored one against the rest. The macro average is the plain mean over classes; the weighted average weights each class by its support. In single-label classification the micro average equals the overall hit rate.
In the label lists, labels may be separated by commas, semicolons, tabs or new lines, so a column pasted from a spreadsheet works as it is. Rows of the matrix are the actual class and columns the predicted one, the layout scikit-learn uses. Numeric labels sort as numbers, so 10 comes after 9.
Edge Cases: 0 ÷ 0, Imbalanced Sets and Mismatched Lists
- A ratio with nothing in its denominator is shown as undefined, with the reason, never as 0% or 100%. A model that never predicts positive (TP 0, FP 0, FN 5, TN 95) has no precision at all. Its F1 is 0, as scikit-learn reports it. In the class averages an undefined score counts as 0, again matching scikit-learn's default.
- When fewer than 10% (or more than 90%) of cases are positive and accuracy runs more than 5 points above balanced accuracy, a note appears. Press Load Sample twice for a set where only 1.2% of cases are positive and accuracy is 99.40%, yet a model that always said “negative” would score 98.8%. Recall there is just 66.67%.
- The two label lists pair up item by item. If their lengths differ you see, for example: “Actual has 12 labels and predicted has 11. They pair up one to one, in the same order, so the counts must match.”
- Counts must be whole numbers. 1,250 is read as a thousands comma; anything else with a comma is refused. Up to 20,000 labels per list and 30 classes.