Skip to content

Confusion Matrix Examples: Accuracy, Precision, Recall And F1

July 3, 2026 ·
Four Classification Outcomes And Three Performance Metric Indicators

A confusion matrix summarizes how a classification system’s predictions compare with known reference outcomes. It shows correct and incorrect decisions separately, making it possible to distinguish missed cases from unnecessary alerts. This distinction is important in machine learning, inspection, document routing, and many ordinary operational decisions. A single accuracy percentage can obscure consequential errors when the condition of interest is uncommon or when different types of mistakes carry different costs. The worked examples below explain the calculation, compare thresholds, and show how to evaluate the results without assuming that one metric establishes overall decision quality.

Quick Answer

A confusion matrix counts true positives, false positives, false negatives, and true negatives. Calculate precision from predicted positives, recall from actual positives, and accuracy from all records. Choose metrics that reflect the consequences of errors.

Table Of Contents

Understanding The Four Binary Outcomes

In a binary classification problem, define the positive class first. It might be a request that actually needs a specialist review, an item that is truly defective, or a transaction that belongs to a particular category. A positive prediction means that the classification system identifies the record as belonging to that class. The reference outcome must be determined through an appropriate independent labeling or verification procedure.

A true positive occurs when the system predicts positive and the reference outcome is positive. A false positive occurs when the system predicts positive but the reference outcome is negative. A false negative occurs when the system predicts negative even though the reference outcome is positive. A true negative occurs when the prediction and reference outcome are both negative.

The Google Machine Learning Crash Course guide to thresholds and confusion matrices provides a conventional explanation of these outcomes. Different tables may place predictions in rows or columns, so axis labels are essential. In the examples here, rows represent predicted classes and columns represent actual classes.

Predicted ClassActually PositiveActually Negative
PositiveTrue Positive (TP)False Positive (FP)
NegativeFalse Negative (FN)True Negative (TN)

The word positive does not necessarily mean desirable. In a quality inspection system, the positive class might be a defective item. In a document-routing system, it might mean a record requiring additional attention. Use labels that preserve the intended meaning rather than infer the business consequence from the word positive alone.

Worked Example: Identifying Requests That Need Specialist Review

Imagine an administrative service receiving applications for a program. Some requests require specialist review under an established rule, while others can follow a standard procedure. A classification tool flags requests that might need additional review. A team independently determines the correct classification for 1,000 representative records under the documented rule.

Suppose 100 records actually need specialist review and 900 do not. The tool identifies 80 of the 100 specialist cases, misses 20, and incorrectly flags 90 ordinary cases. It correctly leaves 810 ordinary cases unflagged. These hypothetical counts form the confusion matrix.

Predicted ClassActually Needs ReviewActually StandardRow Total
Flag For Review8090170
Standard Route20810830
Column Total1009001,000

The totals reconcile: 80 + 90 + 20 + 810 equals 1,000. The positive reference class contains 100 records, while the positive prediction group contains 170 records. These two denominators matter because precision and recall answer different questions.

Accuracy is the fraction of all records classified correctly. The numerator is 80 + 810 = 890, giving 89% accuracy. However, accuracy alone cannot explain whether the system effectively identifies the cases requiring specialist attention.

Precision is the fraction of positive predictions that are actually positive. In this example, precision is 80/(80 + 90) = 80/170, approximately 47.06%. A reviewer examining flagged cases would therefore encounter slightly more false flags than true specialist cases.

Recall, sometimes called sensitivity or true positive rate, is the fraction of actual positive records identified by the system. Recall equals 80/(80 + 20) = 80%. The remaining 20% of specialist cases are missed under this classification rule.

Specificity, or true negative rate, is the fraction of actual negative records correctly identified as negative. It equals 810/(810 + 90) = 90%. The false positive rate is its complement, 90/900 = 10%. The false negative rate is the complement of recall, 20/100 = 20%.

MetricCalculationResult
Accuracy890 / 1,00089.00%
Precision80 / 17047.06%
Recall80 / 10080.00%
Specificity810 / 90090.00%
False Positive Rate90 / 90010.00%
False Negative Rate20 / 10020.00%

The Google guide to classification metrics explains the mathematical definitions and their differing denominators. An operational decision must connect those definitions to the actual consequences of the errors.

Calculating And Interpreting The F1 Score

The F1 score is the harmonic mean of precision and recall. In terms of counts, it can be calculated as twice the true positive count divided by twice the true positive count plus the false positive and false negative counts.

For the specialist-review example, the numerator is 160. The denominator is 160 + 90 + 20 = 270. The F1 score is approximately 0.5926, or 59.26% when expressed as a percentage.

F1 is useful when both precision and recall matter and a single summary of those two measures is desired. It does not include true negatives directly. A high F1 score therefore does not establish that every important aspect of a system is satisfactory. Nor does the ordinary F1 formula automatically account for the actual difference between the costs of false positives and false negatives.

If missed specialist cases have substantially greater consequences than unnecessary reviews, a team may choose a minimum recall requirement and evaluate precision and workload among settings that satisfy it. Other objectives can justify different trade-offs. The decision quality guide explains why a performance score should support an explicit decision purpose rather than become the purpose itself.

Worked Example: Why High Accuracy Can Be Misleading

Consider 1,000 additional records, of which only ten truly belong to the positive class. A simple classifier labels every record negative. It produces 990 true negatives, ten false negatives, zero true positives, and zero false positives.

Accuracy is 990/1,000 = 99%. Recall is zero because the tool detects none of the actual positives. Precision is undefined under the ordinary formula because the number of positive predictions is zero. Specificity is 100%.

This example demonstrates that an apparently impressive accuracy figure can describe an entirely unhelpful detector for the positive class. Always compare the result with a meaningful baseline and report the relevant class distribution. If positive cases are rare, the positive-class metrics may be more informative about the system’s intended purpose.

The distinction also matters for business reporting. Suppose a dashboard reports 99% correct classifications without showing that the tool misses every case requiring additional attention. A manager may mistakenly reduce specialist staffing or remove an independent check. Preserve the underlying counts and explain undefined metrics instead of replacing them with attractive values.

Worked Example: Compare Two Classification Thresholds

Many classification systems produce a numerical score and use a threshold to choose a class. A lower threshold typically flags more records, increasing or preserving recall while potentially reducing precision. The actual results depend on how scores are distributed across classes, and a comparison should use the same evaluation population.

Suppose the administrative service evaluates two threshold settings on the original 1,000 records. The stricter setting is the one already analyzed. A more permissive setting identifies 95 actual specialist cases and incorrectly flags 180 ordinary cases. It therefore misses five specialist cases and correctly leaves 720 ordinary cases unflagged.

Metric Or CountStricter SettingMore Permissive Setting
True Positives8095
False Positives90180
False Negatives205
True Negatives810720
Accuracy89.00%81.50%
Precision47.06%34.55%
Recall80.00%95.00%
Total Flagged170275

The permissive setting identifies 15 additional specialist cases at the expense of 90 additional false flags. It creates 105 more flagged records requiring attention. A manager who focuses solely on accuracy would select the stricter setting. A manager whose primary objective is detecting at least 95% of specialist cases might select the permissive setting if other requirements and resource constraints are met.

Suppose a hypothetical false negative causes $100 in expected operational rework and a false positive causes $5 in unnecessary review cost. Under this simplified error-cost model, the stricter setting costs 20 × $100 + 90 × $5 = $2,450. The permissive setting costs 5 × $100 + 180 × $5 = $1,400. These illustrative costs favor the permissive threshold.

The break-even trade-off can be calculated directly. Detecting 15 more positives prevents 15 false negatives but creates 90 false positives. If the false positive cost remains $5, the permissive setting has a lower modeled error cost when each prevented false negative is worth more than $30. This threshold assumes the error costs are linear, comparable, and complete. It does not capture queue delays, mandatory requirements, or other effects unless those are included explicitly.

Use capacity planning to examine whether reviewers can handle the extra demand. If review capacity is limited to 200 records per period, neither high recall nor favorable modeled error cost makes a 275-record workload automatically feasible.

How Class Prevalence Changes Precision

Suppose a system retains an 80% recall rate and a 10% false positive rate when the underlying share of specialist cases changes from 10% to 2%. For 1,000 records, the new reference population would contain 20 positive and 980 negative records.

Under the assumed constant conditional rates, expected counts are 16 true positives, four false negatives, 98 false positives, and 882 true negatives. Precision falls to 16/(16 + 98), approximately 14.04%, even though recall and false positive rate have not changed.

This result explains why precision measured in one population may not generalize to another with different prevalence. A test set artificially balanced to contain equal numbers of positive and negative records can help estimate some conditional performance measures, but its raw precision may not represent the deployed population.

The assumption that conditional rates remain unchanged also needs verification. A different location or season may change both class prevalence and the difficulty of recognizing cases. Use data stratification to inspect performance across relevant operating conditions. Avoid drawing conclusions about individuals from subgroup averages or treating group differences as self-explanatory.

Multiclass Confusion Matrix Example

A multiclass confusion matrix extends the same idea to more than two categories. Suppose an organization routes document requests to billing, scheduling, or general support. The reference team labels 300 requests, with 100 in each category. The system produces the following illustrative counts.

Predicted CategoryActual BillingActual SchedulingActual General Support
Billing85105
Scheduling88012
General Support71083

Each actual-class column sums to 100. The diagonal contains 85, 80, and 83 correct classifications. Overall accuracy equals 248/300, approximately 82.67%.

Billing precision is 85/(85 + 10 + 5) = 85%. Billing recall is 85/100 = 85%. Scheduling precision is 80/(8 + 80 + 12) = 80%, and scheduling recall is 80/100 = 80%. General support precision is 83/(7 + 10 + 83) = 83%, and recall is 83/100 = 83%.

In this deliberately balanced example, row and column totals are all 100, making per-class precision and recall equal. That is not a general property of multiclass classification. In an unbalanced matrix, the same class may have very different precision and recall.

Macro-average precision and recall give equal importance to each class by averaging the class-specific values. Micro-averaging aggregates relevant counts before calculating the metric, giving greater influence to more frequent classes. For ordinary single-label multiclass classification with all classes included, micro-averaged precision, recall, and F1 equal overall accuracy. Select the averaging method according to the intended question, not according to which gives the highest number.

Establishing A Trustworthy Reference Outcome

A confusion matrix is only as trustworthy as the classifications used as reference outcomes. If a reviewer applies a different definition of specialist need than the one intended for deployment, the counts measure agreement with an inconsistent reference rather than meaningful correctness.

Write a clear operational definition of each category. Review ambiguous cases, preserve the information available at the time of the decision, and avoid using later outcomes that the deployed tool could not reasonably know unless that is the defined prediction target.

When multiple reviewers label cases, evaluate agreement using a suitable measure. The Cohen’s kappa guide explains how chance-adjusted agreement differs from simple agreement. Agreement between reviewers is not proof that the labels are valid, but disagreement can reveal unclear rules or inconsistent interpretation.

Evaluate the system on data not used to select or tune the threshold when possible. If a threshold is chosen because it performs well on a particular evaluation set, reporting that same set as independent confirmation can overstate performance. The principles in A/B testing examples also apply to careful separation of decision selection from subsequent evaluation.

A Practical Confusion Matrix Review Worksheet

Record the positive class, reference procedure, evaluation population, time period, threshold, four outcome counts, calculated metrics, and uncertainty. Preserve missing or unresolved reference labels separately instead of automatically classifying them as negatives. Reconcile the matrix totals with the number of eligible labeled records.

Define what actions follow positive and negative predictions. A system that supplies a review recommendation has a different consequence from one that makes an irreversible eligibility decision automatically. Examine false positive and false negative examples, assess whether error patterns have operational causes, and provide an appropriate route for correction and escalation.

Review the selected setting after deployment. Changes in incoming records, procedures, or classification behavior may alter performance. Keep the raw counts and clear denominator definitions visible in reports. The matrix is valuable because it exposes the kinds of errors the system makes; the responsible decision comes from connecting those errors to the actual service objective, evidence quality, resources, and requirements.

Frequently Asked Questions

What is a confusion matrix?

A table comparing predicted classes with reference outcomes so that correct and incorrect classifications can be counted separately.

What are TP, FP, FN and TN?

True positives, false positives, false negatives and true negatives are the four binary prediction outcomes.

How is accuracy calculated?

Add true positives and true negatives, then divide by all evaluated records.

What is precision?

True positives divided by all positive predictions.

What is recall?

True positives divided by all actual positives.

How is specificity calculated?

True negatives divided by all actual negatives.

What is F1?

The harmonic mean of precision and recall, equivalently 2TP divided by 2TP + FP + FN.

Why can high accuracy be misleading?

A classifier can correctly predict a common class while missing every member of a rare but important class.

What if no positive predictions occur?

Ordinary precision is undefined because its denominator is zero; report the counts and calculation convention.

How should a classification threshold be selected?

Compare relevant error costs, service requirements, capacity, uncertainty and validated performance across feasible settings.

Leave a Reply

Your email address will not be published. Required fields are marked *