Accuracy Calculator

Standard method

Results

Accuracy

0

Sensitivity

0

Specificity

0

1

What is Accuracy Calculator?

Classification accuracy measures how often a model or test assigns the correct class. This calculator takes the four counts in a binary confusion matrix and reports accuracy, sensitivity and specificity. Seeing all three helps you distinguish overall correctness from performance within each actual class.

The same arithmetic can be used for a machine-learning classifier, a quality-control inspection or a diagnostic-test dataset. The numbers only describe the labeled cases provided. They do not establish that a model will perform equally well in another population or that a medical test result is a diagnosis.

2

How to Use This Calculator

Define the positive class before entering any counts. It might be a defective item, a spam message or the presence of a condition. Decide which reference labels establish the actual class. Then compare each predicted result with that reference and tally the four groups.

Enter True positive, False positive, False negative and True negative. Use nonnegative whole counts from one dataset and one decision threshold. Calculate to see percentages rounded to two decimal places.

Check the denominators first. At least one actual positive and at least one actual negative are needed for this implementation to calculate both sensitivity and specificity without a zero denominator. An entirely empty dataset cannot have any of these rates. A dataset containing only one actual class may still have a defined overall accuracy, but one class-specific rate is undefined.

3

Formula Used

Accuracy = (TP + TN) ÷ (TP + TN + FP + FN) × 100. Sensitivity = TP ÷ (TP + FN) × 100. Specificity = TN ÷ (TN + FP) × 100.
4

Variables Explained

InputUnit or choiceMeaning
True positive (TP)CountActual positive predicted positive.
False positive (FP)CountActual negative predicted positive.
False negative (FN)CountActual positive predicted negative.
True negative (TN)CountActual negative predicted negative.

True positives, TP, are actual positive cases correctly predicted positive. False negatives, FN, are actual positive cases incorrectly predicted negative. Adding TP and FN therefore counts all actual positives, whether detected or missed.

True negatives, TN, are actual negative cases correctly predicted negative. False positives, FP, are actual negative cases incorrectly predicted positive. TN plus FP counts all actual negatives. Every labeled case should fall into exactly one of these four groups.

Sensitivity describes detection among actual positives. Specificity describes rejection among actual negatives. Accuracy pools both correct groups over the complete dataset. These definitions depend on which class you named positive, so record that choice whenever sharing the output.

5

Worked Example

Consider TP = 40, FP = 5, FN = 5 and TN = 50. There are 100 cases altogether, of which 90 were correctly classified. Accuracy is therefore 90 percent. Sensitivity is 40 ÷ 45 × 100 = 88.89 percent. Specificity is 50 ÷ 55 × 100 = 90.91 percent.

Now consider an imbalanced dataset with ten actual positives and 990 actual negatives. A classifier that predicts every case negative has TP = 0, FN = 10, TN = 990 and FP = 0. Accuracy is 99 percent, yet sensitivity is zero. The impressive overall percentage hides failure to identify every positive case.

For a less extreme comparison, keep the same dataset but detect eight of ten positives and incorrectly flag twenty negatives. Counts become TP = 8, FN = 2, FP = 20 and TN = 970. Accuracy falls to 97.8 percent, while sensitivity rises to 80 percent. Which error pattern is acceptable depends on the task, not accuracy alone.

6

Why Use This Calculator?

Interpret these outputs alongside the costs of false positives and false negatives. A screening process may prioritize finding positives; a process with costly follow-up may need particular attention to false alarms. This calculator does not assign those costs or select a threshold for you.

For model evaluation, use an appropriate evaluation dataset and explain how the reference labels were obtained. Testing on examples used to build or tune a model can give an overly favorable impression. The arithmetic cannot detect data leakage, mislabeled observations or a sample that differs from deployment conditions.

Do not confuse sensitivity with positive predictive value. Sensitivity asks how many actual positives were detected. Positive predictive value asks how many positive predictions were actually positive and uses TP + FP as its denominator. The latter is not returned by this page.

7

Common Mistakes

    Avoid swapping false positives and false negatives. Trace one actual positive and one actual negative through your labeling process if the headings are unclear. Do not enter percentages from separate reports as though they were raw counts; the denominators would no longer represent one confusion matrix. Do not round class counts or omit uncertain cases without describing how you handled them.

8

Frequently Asked Questions

Why can high accuracy hide a poor classifier?

The majority class can dominate the total. When negatives are much more common, predicting negative most of the time can produce high accuracy while missing positives. Sensitivity and the original class counts expose that limitation.

Is one hundred percent specificity enough to prove a test is perfect?

No. It means there were no false positives among the actual negatives in this dataset. The test can still miss actual positives, and a limited sample does not prove perfect behavior in all future cases.

What happens when there are no actual positives?

Sensitivity would require division by TP + FN = 0 and is undefined. Do not replace it with zero merely to fill a report. Collect an appropriate sample or explicitly mark that class-specific estimate as unavailable.

Can I change which class is positive?

Yes, but the labels and interpretation must change together. Overall accuracy stays the same when both classes are swapped consistently; sensitivity and specificity exchange roles. Keep the positive-class definition with the report.

Can the calculator choose a medical treatment?

No. A confusion matrix summarizes classification performance for a dataset. Treatment decisions involve the person, the clinical context and other evidence that these four counts do not contain.

9

Sources & References