Accuracy is measured by comparing your results to a known true value or correct outcome. The exact method depends on what you’re measuring: a classification model, a diagnostic test, a physical instrument, or a predictive model. But every approach shares the same core idea: how close are your results to reality? The formula, the metrics, and the pitfalls differ by context, so understanding which version of “accuracy” applies to your situation is the first step.
Accuracy vs. Precision
Before diving into formulas, it helps to separate two concepts that often get confused. Accuracy is how close your measurements are to the true value. Precision is how close your measurements are to each other. You can be precise without being accurate: imagine a bathroom scale that consistently reads 5 pounds too high. The readings are tightly clustered (precise) but wrong (inaccurate). In statistics, these same ideas go by different names: bias refers to inaccuracy, and variability refers to imprecision.
A good measurement system needs both. High accuracy with low precision means your results scatter around the correct answer but don’t reliably land on it. High precision with low accuracy means you’re consistently off by the same amount, which can sometimes be corrected through calibration. When someone asks “how accurate is this?” they usually want to know about both properties, even if they only use the word accuracy.
The Basic Accuracy Formula for Classification
The most widely used accuracy formula applies to classification problems, where you’re sorting items into categories (disease vs. no disease, spam vs. not spam, fraud vs. legitimate). It uses four values from what’s called a confusion matrix:
- True positives (TP): correctly identified positive cases
- True negatives (TN): correctly identified negative cases
- False positives (FP): negative cases incorrectly labeled positive
- False negatives (FN): positive cases incorrectly labeled negative
The formula is straightforward: Accuracy = (TP + TN) / (TP + TN + FP + FN). In plain terms, you add up everything you got right and divide by the total number of cases. If you correctly classified 74 out of 95 items, your overall accuracy is 74/95, or about 77.9%.
This formula works for any binary or multiclass classification task. In machine learning, it’s calculated from a confusion matrix after running your model on test data. In medical testing, the same math applies to diagnostic results. The number is intuitive and easy to communicate, which is why it’s the most commonly reported metric. But as you’ll see below, it can also be deeply misleading.
When Overall Accuracy Lies to You
The single biggest trap in measuring accuracy is the accuracy paradox, which shows up whenever your data is imbalanced. Consider a credit card fraud detection model trained on a dataset with 990 legitimate transactions and only 10 fraudulent ones. A model that labels every single transaction as legitimate would achieve 99% accuracy, because it correctly identifies 990 out of 1,000 cases. It also catches zero fraud, making it completely useless.
Now imagine a second model that catches 6 of the 10 fraud cases but incorrectly flags 4 legitimate transactions. Its accuracy drops to 98.6%, lower than the do-nothing model, yet it’s clearly more valuable. This is the accuracy paradox: a model with zero predictive power can score higher on accuracy than a model that actually works, simply because the majority class dominates the calculation.
This problem is common in real-world applications. Rare disease detection, manufacturing defect identification, and network intrusion detection all involve heavily imbalanced classes. In these situations, accuracy alone tells you more about the distribution of your data than about how well your model performs. You need additional metrics.
Sensitivity, Specificity, and Related Metrics
To get a fuller picture, break accuracy into its components. Sensitivity (also called recall) measures how well you catch positive cases: TP / (TP + FN). A highly sensitive test rarely misses a true positive. Specificity measures how well you identify negative cases: TN / (TN + FP). A highly specific test rarely produces false alarms.
These two metrics are inversely related. Tuning a test to catch more true positives typically increases false positives, lowering specificity. A cancer screening designed to never miss a case will flag many healthy patients. A screening designed to minimize false alarms will inevitably miss some cancers. The right balance depends on the consequences of each type of error.
In machine learning, precision (not the same as measurement precision discussed earlier) tells you what proportion of your positive predictions were actually correct: TP / (TP + FP). The F1 score combines precision and recall into a single number, giving you a balanced view when accuracy is unreliable. For imbalanced datasets, the F1 score or area under the ROC curve are generally better choices than raw accuracy.
Measuring Accuracy in Continuous Data
When you’re predicting a number rather than a category (house prices, temperature, stock values), accuracy is measured differently. Two common metrics are mean absolute error (MAE) and root mean square error (RMSE).
MAE calculates the average size of your errors, treating all errors equally. If your predictions are off by 2, 3, and 1, the MAE is 2. RMSE squares each error before averaging and then takes the square root, which penalizes large errors more heavily. A single prediction that’s wildly off will raise RMSE much more than MAE. Neither metric is inherently superior. RMSE works best when your errors follow a bell-curve distribution. MAE is more robust when errors are unevenly distributed or when outliers are present.
The key is choosing the metric that matches what matters in your application. If a large error is disproportionately costly (say, underestimating flood levels), RMSE’s sensitivity to outliers is a feature, not a bug. If all errors are roughly equally bad, MAE gives a more intuitive picture.
Accuracy in Physical Measurement
For lab instruments, manufacturing tools, or scientific equipment, accuracy is measured through calibration against a known standard. The process involves comparing your instrument’s readings to a reference value that’s traceable to an official measurement standard. The difference between your reading and the reference value tells you how accurate your instrument is.
Every physical measurement carries some uncertainty. Calculating that uncertainty requires defining what you’re measuring, identifying every factor that could introduce error (temperature fluctuations, instrument drift, human reading variation), and quantifying each source. The combined uncertainty gives you a range: instead of saying “this sample weighs 5.00 grams,” you’d say “5.00 grams plus or minus 0.02 grams.” That range is what separates a casual measurement from a scientifically defensible one.
Regular calibration is essential because instruments drift over time. A thermometer that was accurate last year may read half a degree high today. Calibration schedules depend on the instrument type, how often it’s used, and how tight your accuracy requirements are.
Sample Size and Statistical Accuracy
In surveys and studies, accuracy depends heavily on sample size and variability. The margin of error tells you how much your sample results might differ from the true population value. A political poll with a 3% margin of error and 95% confidence level means that if you repeated the survey many times, 95% of the results would fall within 3 percentage points of the true value.
Three factors control the width of that margin. First, larger samples produce smaller margins of error, because more data points reduce the influence of random variation. Second, less variability in your data (a smaller standard deviation) tightens the margin. Third, higher confidence levels widen it: being 99% confident requires a wider range than being 95% confident. In practice, many sample size calculations start by deciding the acceptable margin of error and working backward to determine how many responses you need.
Choosing the Right Accuracy Metric
The best way to measure accuracy depends entirely on what you’re evaluating. For a binary classifier with balanced classes, overall accuracy (TP + TN over total) works well. For imbalanced data, use the F1 score or report sensitivity and specificity separately. For regression models predicting continuous values, choose MAE for a straightforward average error or RMSE when large errors need extra weight. For physical instruments, calibrate against a traceable standard and report your measurement uncertainty. For surveys, report the margin of error alongside your confidence level and sample size.
No single number captures everything. Reporting accuracy without context, whether it’s the class balance of your dataset, the uncertainty of your instrument, or the confidence level of your survey, leaves out information your audience needs to judge whether that number is actually good.

