Mathematics calculator

Classification Accuracy Calculator

Calculate accuracy, sensitivity, and specificity from the four counts in a binary classification confusion matrix.

Calculator inputs

Enter your values

Confusion matrix
Calculated output

Result summary

Your result will appear here

Complete the required fields and select the calculate button.

What Is Classification Accuracy?

Classification accuracy is the share of predictions that match their actual labels. For a binary classifier, correct predictions are true positives plus true negatives. This accuracy calculator also reports sensitivity, the share of actual positives detected, and specificity, the share of actual negatives correctly rejected.

Enter four confusion-matrix counts from one evaluation set. The calculator reports descriptive percentages and correct/incorrect totals. It does not estimate measurement percent error, predictive precision, confidence intervals or performance on a different population.

How to Enter Confusion Matrix Counts

  1. Define which outcome is positive and compare each prediction with a reliable actual label.
  2. Enter the nonnegative integer counts for True positives, False positives, False negatives and True negatives. Use counts, not percentages.
  3. Include at least one actual positive and one actual negative case. The form needs both classes to compute sensitivity and specificity.
  4. Select Calculate. Review all three metrics and the correct, incorrect and total counts rather than judging performance from accuracy alone.

True means the prediction matches the actual label; false means it does not. Positive and negative name the prediction class, not whether the outcome is good or bad. False positives are actually negative, while false negatives are actually positive.

All four counts must come from the same evaluation setting and classification threshold. The three percentages display two decimal places. The form does not validate reference-label quality, representative sampling or independence of evaluation from model training.

Accuracy, Sensitivity and Specificity Formulas

Total N = TP + FP + FN + TN

Accuracy = (TP + TN)/N × 100%

Sensitivity = TP/(TP + FN) × 100%

Specificity = TN/(TN + FP) × 100%

Correct = TP + TN; incorrect = FP + FN

Sensitivity is also called recall or true positive rate. Specificity is the true negative rate, equivalently recall when the negative class is treated as the target. Their denominators group by the actual class.

Precision asks a different question: TP/(TP + FP), among predicted positives. This page does not output precision. Sensitivity and specificity require nonzero actual-positive and actual-negative totals, so the calculator rejects a missing actual class even if overall accuracy alone would be defined.

Reference: Google Machine Learning: Classification Metrics. Accuracy, recall, precision, false-positive rate and class-imbalance limitations. Form bounds, formatting and numerical limitations follow this calculator’s implementation.

True and False Predictions Explained

True positives TP
Actually positive cases predicted positive.
False positives FP
Actually negative cases predicted positive.
False negatives FN
Actually positive cases predicted negative.
True negatives TN
Actually negative cases predicted negative.
Overall accuracy
Featured correct/total percentage, shown to two decimals.
Sensitivity
Percent of actual positives predicted positive.
Specificity
Percent of actual negatives predicted negative.
Correct, incorrect and total cases
Raw totals for checking that TP, FP, FN and TN cover the same evaluated cases.

Classification Accuracy Worked Example

Illustrative example. An evaluation set has TP = 36, FP = 9, FN = 4 and TN = 51. These are hypothetical labeled counts from one binary classifier.

There are 100 cases, 87 correct predictions and 13 errors. Accuracy = 87/100 = 87.00%. Sensitivity = 36/40 = 90.00%, and specificity = 51/60 = 85.00%.

Independently sum by actual class: 40 positives and 60 negatives. Weight their correctly classified shares: 0.40 × 0.90 + 0.60 × 0.85 = 0.87, matching accuracy. The table records the same confusion matrix by actual class.

Calculation check. These illustrative values were checked independently against the formula and calculator response. Retain unrounded intermediate values when checking approximations.

Classification Accuracy Worked Example
Actual classPredicted positivePredicted negative
Positive: 40 casesTP = 36FN = 4
Negative: 60 casesFP = 9TN = 51
Prediction totals4555

Why High Accuracy Can Hide Missed Positives

Consider a hypothetical set with 5 actual positives and 95 actual negatives. A classifier that predicts negative for every case has 95 correct negatives but misses all five positives.

It scores 95% accuracy, 0% sensitivity and 100% specificity. All three are mathematically consistent. Comparing the metrics reveals a failure hidden by the headline accuracy.

Why High Accuracy Can Hide Missed Positives
ScenarioAccuracySensitivitySpecificity
Main example: TP 36, FP 9, FN 4, TN 5187%90%85%
Always negative: TP 0, FP 0, FN 5, TN 9595%0%100%
Perfect on that set: TP 5, FP 0, FN 0, TN 95100%100%100%

How to Interpret Accuracy with Class Imbalance

Accuracy weights each case equally, so a common class can dominate the result. If a set has 95 negatives and 5 positives, predicting negative every time gives 95% accuracy but 0% sensitivity. The classifier has missed every positive despite its high headline score.

Sensitivity and specificity expose different types of mistakes. Compare their values with the costs of false negatives and false positives in the actual task. There is no universal score that makes a classifier suitable for every use.

These percentages describe the submitted evaluation counts. Different class proportions, thresholds, reference labels or data sources can change the results. The form provides no uncertainty interval or evidence of external validity; a score from a small or unrepresentative sample is not a guarantee for future cases.

Common Accuracy Calculation Mistakes

  • Swapping false positives with false negatives.
  • Entering percentages instead of counts.
  • Using TP + FP as the sensitivity denominator.
  • Confusing accuracy with precision.
  • Ignoring class imbalance or a zero sensitivity.
  • Combining counts from different evaluation sets or thresholds.

Frequently Asked Questions

How do I calculate classification accuracy?

Add true positives and true negatives, divide by all four confusion-matrix counts and multiply by 100.

What is sensitivity?

Sensitivity is TP/(TP + FN), the share of actual positives detected. It is also called recall or true positive rate.

What is specificity?

Specificity is TN/(TN + FP), the share of actual negatives correctly predicted negative. It is the true negative rate.

Is accuracy the same as precision?

No. Accuracy uses all cases, while precision is TP/(TP + FP), among predicted positives. This calculator does not display precision.

Why can 95% accuracy still be misleading?

In a set with 95 negatives and 5 positives, predicting negative every time gives 95% accuracy but 0% sensitivity. The positive class is missed entirely.

Why must the counts include both actual classes?

The form computes sensitivity and specificity together. Their denominators require at least one actual positive and one actual negative, even if accuracy alone would be defined.

Can I enter percentages instead of counts?

No. Enter nonnegative whole-number counts for TP, FP, FN and TN from the same evaluation set and threshold.

Does the result guarantee future performance?

No. It describes the submitted counts. Sampling, reference-label quality, class proportions and changing conditions affect how well it represents future cases.

Sources and References