Classification Accuracy Calculator

Classification Accuracy Calculator

Score a yes/no classifier from its true and false positives and negatives: accuracy, balanced accuracy, precision, recall, F1 and the Matthews correlation coefficient, with a warning when accuracy flatters.

Accuracy = (TP + TN) ÷ total

Positive = the class you're trying to detect (spam, fraud, disease). Top row: predicted positive. Bottom row: predicted negative.

Enter all four counts

What Is Classification Accuracy?

Classification accuracy is the share of all predictions a model gets right. It's the most natural score, and the most misleading when one outcome is much rarer than the other.

If 1% of transactions are fraudulent, a model that never flags anything is 99% accurate and completely useless. This is the accuracy paradox. For rare targets, you need metrics that focus on the positive class.

Precision asks how many flagged cases are real. Recall asks how many real cases were caught. F1 balances the two. The Matthews correlation coefficient (MCC) uses all four counts and stays honest even when classes are badly imbalanced.

Classification Accuracy Formulas

As given in Powers (2011) and Chicco & Jurman (2020). See Sources.

1. Accuracy and balanced accuracy

accuracy = (TP + TN) ÷ N · balanced = (recall + specificity) ÷ 2

2. Precision, recall and F1

precision = TP ÷ (TP + FP) · recall = TP ÷ (TP + FN) · F1 = 2TP ÷ (2TP + FP + FN)

3. Matthews correlation coefficient

MCC = (TP × TN − FP × FN) ÷ √((TP+FP)(TP+FN)(TN+FP)(TN+FN))

MCC is the correlation between predicted and actual labels. It's only high when the model does well on both classes.

Worked Example: A Fraud Detector That Looks 99% Accurate

Given:
Of 10,000 transactions, 100 are fraudulent. The model flags 100: 40 real frauds and 60 innocent customers.
Step 1:
Accuracy:
(40 + 9,840) ÷ 10,000 = 98.8%
Step 2:
Compare with doing nothing:
never flag anything → 9,900 ÷ 10,000 = 99.00%
Step 3:
Positive-class metrics:
precision 40% · recall 40% · F1 40% · MCC 0.394
Result:
98.8% accurate, but F1 = 0.4

The model is slightly less accurate than doing nothing, yet it catches 40% of fraud. Accuracy can't see that trade-off. F1 and MCC show a modest model with room to improve.

Which Classification Metric to Use

Choosing a classification metric by situation
SituationFocus on
Classes roughly balanced, errors equally costlyAccuracy
False alarms are expensive (spam filter, arrests)Precision
Missing a case is dangerous (cancer screening)Recall
Rare positive class, one summary numberF1 or MCC
Comparing models on imbalanced dataMCC or balanced accuracy

Common Classification Accuracy Mistakes

  • Celebrating high accuracy on imbalanced data. Always compare with the score of predicting the majority class every time.
  • Mixing up FP and FN. A false positive is a wrong alarm; a false negative is a missed case. Swapping them swaps precision and recall.
  • Reporting precision without recall. Flagging just one sure case gives 100% precision while missing everything else.
  • Scoring on the training data. Metrics must come from data the model hasn't seen, or they overstate performance.

Classification Accuracy FAQs

What is a good F1 score?

It depends on the task and the base rate. Compare against a simple baseline and other models on the same data rather than a fixed threshold.

Why is MCC recommended?

It’s only high when the model does well on positives and negatives, so it can’t be gamed by the majority class.

What does “undefined” mean?

A metric divides by zero, for example precision when the model flagged nothing. Report it as undefined, not 0 or 100%.

Is recall the same as sensitivity?

Yes. Machine learning says recall; medicine says sensitivity.

What about more than two classes?

Use the confusion matrix calculator, which gives per-class scores and macro and micro averages.

What is balanced accuracy?

The average of recall and specificity. A model that always guesses one class scores 50%.

How do I improve recall?

Lower the decision threshold. That usually lowers precision too; choose the trade-off that suits the costs.

Is F1 symmetric in the two classes?

No, it ignores true negatives. Swap which class you call positive and F1 changes; MCC doesn’t.

Sources

  • D. Chicco and G. Jurman, "The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy in binary classification evaluation", BMC Genomics 21 (2020), doi:10.1186/s12864-019-6413-7.
  • D. M. W. Powers, "Evaluation: from precision, recall and F-measure to ROC, informedness, markedness and correlation", Journal of Machine Learning Technologies 2 (2011).

Related Tools