Accuracy Calculator

Quick answer

The accuracy calculator works out how often a test or classifier is right – from a confusion matrix (TP, FN, FP, TN), from sensitivity, specificity and prevalence, or as 100% minus the percent error of a measurement compared with an accepted value.

Accuracy
92.5 %
Sensitivity (true positive rate)
90 %
Specificity (true negative rate)
93.3333 %
Balanced accuracy
91.6667 %
Error rate (misclassification)
7.5 %
Precision / positive predictive value
81.8182 %
Prevalence in the table
25 %
Total cases
200

Accuracy is the share of all decisions that turn out correct. For a medical test, spam filter or machine-learning model it is the number of true positives plus true negatives divided by every case tested. For a measuring instrument it describes how close a reading is to the accepted (true) value, which is usually expressed through the percent error.

The calculator offers three methods. With a confusion matrix you type the four counts and get accuracy together with sensitivity, specificity, balanced accuracy, error rate, prevalence and precision. If you only know a test’s sensitivity and specificity, enter the prevalence of the condition in the population you care about – accuracy changes with prevalence because it weights the two rates by how common each group is. The third method compares an observed measurement with an accepted value.

A single accuracy figure can mislead when one class is rare. A test that calls everyone healthy is 99% accurate when 1% of people are ill, yet it finds nobody. That is why balanced accuracy and the separate rates are shown next to it.

How to use the Accuracy Calculator

  1. Method
  2. True positives (TP)
  3. False negatives (FN)
  4. False positives (FP)
  5. True negatives (TN)
  6. Sensitivity
  7. Specificity
  8. Prevalence
  9. Observed (measured) value
  10. Accepted (true) value

Results update as you type, and everything is calculated in your browser.

How it works

In matrix mode the correct decisions (TP + TN) are divided by the total. In prevalence mode the sensitivity is weighted by the prevalence and the specificity by the share without the condition. In percent-error mode the absolute difference between the observed and accepted values is divided by the accepted value and subtracted from 100%.

Worked example

A screening test is run on 200 people: 45 true positives, 5 false negatives, 10 false positives and 140 true negatives. Accuracy = (45 + 140) ÷ 200 = 92.5%. Sensitivity = 45 ÷ 50 = 90%, specificity = 140 ÷ 150 = 93.33%, so balanced accuracy = 91.67%. Precision is 45 ÷ 55 = 81.82%, and the prevalence in this sample is 50 ÷ 200 = 25%.

Which accuracy measure to use

Situation Better measure
Classes roughly balanced Accuracy
Positive class rare (under 10%) Balanced accuracy, sensitivity, precision, F1
Measuring instrument vs reference Percent error (accuracy = 100% − error)
Test used in a different population Recalculate with that population’s prevalence

Inputs explained

Field What to enter
Method Choose one: Confusion matrix counts, Sensitivity, specificity and prevalence, Measured vs accepted value (percent error)
True positives (TP) A number
False negatives (FN) A number
False positives (FP) A number
True negatives (TN) A number
Sensitivity In %
Specificity In %
Prevalence In %
Observed (measured) value A number
Accepted (true) value A number

What each result means

  • Balanced accuracy = ([Sensitivity (true positive rate)] + [Specificity (true negative rate)])÷2
  • Error rate (misclassification) = 100 – [Accuracy]
  • Prevalence in the table = ([True positives (TP)] + [False negatives (FN)])÷([True positives (TP)] + [False negatives (FN)] + [False positives (FP)] + [True negatives (TN)])×100
  • Total cases = [True positives (TP)] + [False negatives (FN)] + [False positives (FP)] + [True negatives (TN)]
  • Percent error = abs([Observed (measured) value] – [Accepted (true) value])÷abs([Accepted (true) value])×100
  • Absolute error (observed − accepted) = [Observed (measured) value] – [Accepted (true) value]

Formula

Accuracy = (TP + TN) ÷ (TP + TN + FP + FN) Accuracy = Sensitivity × Prevalence + Specificity × (1 − Prevalence) Percent error = |Observed − Accepted| ÷ |Accepted| × 100%, Accuracy = 100% − percent error

Worked example

Inputs — Method: Confusion matrix counts; True positives (TP): 45; False negatives (FN): 5; False positives (FP): 10; True negatives (TN): 140.
Results — Accuracy = 92.5 %; Sensitivity (true positive rate) = 90 %; Specificity (true negative rate) = 93.3333 %; Balanced accuracy = 91.6667 %; Error rate (misclassification) = 7.5 %; Precision / positive predictive value = 81.8182 %; Prevalence in the table = 25 %; Total cases = 200.

Key terms

Confusion matrix
A 2 × 2 table of true positives, false positives, false negatives and true negatives.
Sensitivity
The share of real positives that the test detects, TP ÷ (TP + FN).
Specificity
The share of real negatives correctly cleared, TN ÷ (TN + FP).
Percent error
The size of a measurement error relative to the accepted value, in percent.

Frequently asked questions

What is a good accuracy?

It depends on the base rate. With 50/50 classes, 90% is strong; with a 1% positive class, 99% can be achieved by always answering "negative", so look at sensitivity and balanced accuracy too.

How do I calculate accuracy from sensitivity and specificity?

Accuracy = sensitivity × prevalence + specificity × (1 − prevalence). With 90% sensitivity, 95% specificity and 10% prevalence it is 0.9 × 0.1 + 0.95 × 0.9 = 94.5%.

Is accuracy the same as precision?

No. Accuracy is closeness to the true value (or the share of correct decisions); precision is how repeatable results are, or in classification the share of positive calls that are correct.

Can accuracy be negative?

Not as a share of correct decisions. With the percent-error method, an error larger than 100% would give a negative number, which simply means the measurement is off by more than the accepted value itself.

What is balanced accuracy?

The average of sensitivity and specificity. It is not affected by class imbalance, so it is preferred for rare conditions.

How do I turn percent error into accuracy?

Subtract it from 100%. A thermometer reading 98.2 °F when the accepted value is 98.6 °F has a 0.41% error, so it is about 99.59% accurate.

Why does accuracy change with prevalence?

Because it averages sensitivity and specificity weighted by how many people are in each group. A test with poor sensitivity looks better in a population where almost nobody has the condition.

Sources

  1. CDC – Sensitivity, specificity and predictive values (Principles of Epidemiology)
  2. scikit-learn – Model evaluation: classification metrics
  3. NIST/SEMATECH e-Handbook of Statistical Methods

Cite this calculator

Speedy Calculator. (2026). Accuracy Calculator. Speedy Calculator. https://speedycalculator.com/calculators/statistics/accuracy/