Accuracy Calculator

Compute classification accuracy from a confusion matrix — enter true positives, true negatives, false positives, and false negatives to get accuracy, error rate, and the total sample size.

Quick Facts

Formula
Accuracy = (TP + TN) / (TP + TN + FP + FN)
Correct predictions divided by the total number of predictions.

Your Results

Calculated
Accuracy
-
Share of correct predictions
Error rate
-
1 − accuracy
Correct predictions
-
TP + TN
Total predictions
-
TP + TN + FP + FN

Ready

Enter your confusion-matrix counts and press Calculate.

What accuracy measures

Accuracy is the most common single-number summary of how well a classifier performs. It answers a simple question: out of every prediction the model made, what fraction did it get right? In a binary classification problem, each prediction falls into one of four cells of a confusion matrix — true positive (TP), true negative (TN), false positive (FP), and false negative (FN). Accuracy adds up the two "correct" cells and divides by the total.

The formula

Accuracy = (TP + TN) / (TP + TN + FP + FN)

Equivalently, accuracy is simply the number of correct predictions divided by the total number of predictions. It is a pure ratio between 0 and 1, and is usually reported as a percentage by multiplying by 100. The error rate is its complement: error rate = 1 − accuracy = (FP + FN) / (TP + TN + FP + FN).

What the four cells mean

  • True positive (TP): the actual label is positive and the model correctly predicted positive.
  • True negative (TN): the actual label is negative and the model correctly predicted negative.
  • False positive (FP): the actual label is negative but the model wrongly predicted positive (a "false alarm", or Type I error).
  • False negative (FN): the actual label is positive but the model wrongly predicted negative (a "miss", or Type II error).

A worked example

Suppose a spam filter is evaluated on 200 emails: TP = 85, TN = 90, FP = 10, FN = 15. Correct predictions = 85 + 90 = 175, and the total = 200. Accuracy = 175 / 200 = 0.875 = 87.5%, so the error rate is 12.5%. The filter labelled 25 emails incorrectly (10 legitimate emails flagged as spam, and 15 spam emails let through).

Why accuracy alone can mislead

Accuracy weights every prediction equally, which is a problem when the classes are imbalanced. If 99% of transactions are legitimate and 1% are fraud, a model that predicts "legitimate" for everything reaches 99% accuracy while catching zero fraud. Whenever one class dominates, always report accuracy alongside precision (TP / (TP + FP)), recall (TP / (TP + FN)), and F1 score, or use balanced accuracy — the average of recall on each class.

Frequently Asked Questions

What is the formula for accuracy?
Accuracy = (TP + TN) / (TP + TN + FP + FN) — the count of correct predictions divided by the total number of predictions. Multiply by 100 to get a percentage. For example, 175 correct out of 200 total is 175/200 = 0.875 = 87.5%.
What is the difference between accuracy and precision?
Accuracy measures overall correctness across both classes: (TP + TN) / total. Precision only looks at the positive predictions — TP / (TP + FP) — answering "when the model says positive, how often is it right?" A model can have high accuracy but low precision (or vice versa), which is why both are usually reported together with recall.
Why is my accuracy high but the model still seems bad?
This is the classic imbalanced-data trap. If one class makes up most of the data, always predicting that class yields high accuracy while the model learns nothing useful. Compare your accuracy to the majority-class baseline (the frequency of the most common class), and look at recall on the minority class or the full confusion matrix.
Can accuracy be used for more than two classes?
Yes. For multi-class problems, accuracy is still correct predictions divided by total predictions — the sum of the diagonal of the confusion matrix divided by the sum of all cells. This calculator uses the binary TP/TN/FP/FN form; for a multi-class task, add up all correctly classified samples as the numerator and all samples as the denominator.