Calculate within each class, then average
Sensitivity TP/(TP + FN) is recall of the actual positive class. Specificity TN/(TN + FP) is recall of the actual negative class. Unadjusted binary balanced accuracy gives each of these rates weight one half. Both actual-class counts must be known and positive for this calculation. The procedure does not alter training data; it specifies how an existing test result is summarized.[1][2]
Ordinary accuracy counts all correct cases and divides by the entire test set. It can be written as the same two class rates weighted by actual class frequencies. If actual classes have equal size, both weights are one half, so accuracy and balanced accuracy coincide. They also coincide when the two class-specific rates are equal.[2]
Here actual class frequencies weight the class-specific rates; N is total sample size.[2]
Example 1: 70% despite 64% overall accuracy
20 actual positives and 80 negatives
- Given
- An original model evaluation has TP = 16, FN = 4, TN = 48 and FP = 32.
- Find
- Find both class rates, balanced accuracy and accuracy.
Calculate each rate within its actual class.
Each class counts equally in balanced accuracy.
The overall rate instead gives more weight to the more frequent negative class.
Result: Balanced accuracy is 70%, while accuracy is 64%. These are different weightings of the same classification outcomes.
Check: The matrix contains exactly 20 positives and 80 negatives. The mean 0.70 lies between class rates 0.60 and 0.80.
Recall the method later with the formula’s flashcards.
10 flashcards · English materials
Already have an account? Sign in for flashcardsAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Example 2: predicting the majority class is not enough
Two model scenarios on the same imbalanced test set
- Given
- The original test set contains 10 actual positives and 90 negatives. A always predicts negative. B detects 80% of each class.
- Find
- Explain why the two metrics rank these cases differently.
A misses every positive and correctly classifies every negative.
A has a high overall correct fraction but completely misses the rare class.
B gives TP = 8, FN = 2, TN = 72 and FP = 18. Both class-specific rates are equal.
Result: Accuracy prefers A, 90% versus 80%. Balanced accuracy prefers B, 80% versus 50%, because detecting the positive class receives equal weight.
Check: Both scenarios use identical actual class counts and the same 100 cases. The figure depicts these exact constructed matrices, not measured product performance.
Range, adjustment and missing classes
The unadjusted score calculated here lies between 0 and 1. Perfect detection of both classes gives 1. A constant prediction gives 0.5 when both actual classes are present, because one class rate is 1 and the other is 0. A score of 0.5 therefore does not prove random prediction. The class-specific rates and counts explain how the average arose.[1][2]
Chance adjustment produces a different reported score. In the binary case it maps BA to 2BA − 1, sending 0.5 to zero. This page’s calculator explicitly uses the unadjusted version. State this setting when comparing software outputs. The Matthews correlation coefficient also has a signed range, but computes a different function of the matrix and is not this adjustment.[1]
If one actual class is entirely absent from a binary test set, its empirical detection rate cannot be determined. The calculator reports this rather than inventing an unobserved class rate. For more than two classes, balanced accuracy is commonly the unweighted mean of the included class recalls; the class set and treatment of missing classes must be specified. Equal class weight in a metric also does not guarantee fair decisions or appropriate error costs.[1][2]
Five exercises on class weighting
Calculate · Foundation
Calculate balanced accuracy for TP = 18, FN = 6, TN = 56 and FP = 14.
Show hint
The denominators are 24 and 70.
Learning goal: Calculate two class-specific rates separately and average them equally.
Error analysis · Application
90% of actual cases are positive. Sensitivity is 80%; specificity is 60%. Someone calls 0.9 × 0.8 + 0.1 × 0.6 = 0.78 balanced accuracy. Correct this.
Show hint
BA’s two weights do not depend on class frequency.
Learning goal: Avoid reporting frequency-weighted overall accuracy as balanced accuracy.
Show solution and calculation
0.78 is ordinary accuracy under the stated class frequencies.
Balanced accuracy gives each class weight 1/2 and equals (0.8 + 0.6)/2 = 0.70.
Rearrange · Application
Exact balanced accuracy is 82%, and sensitivity is 90%. Find specificity.
Show hint
Solve 2BA = TPR + TNR for TNR.
Learning goal: Recover a missing class rate from an exact mean.
Show solution and calculation
TNR = 2 × 0.82 − 0.90 = 0.74, or 74%.
It lies in the allowed range.
Checking (0.90 + 0.74)/2 reproduces 0.82.
Interpret · Application
A test set has 5 positives and 95 negatives. A model always predicts negative. Explain its accuracy and balanced accuracy.
Show hint
Detection rate for actual positives is zero.
Learning goal: Distinguish constant prediction from detecting both classes.
Show solution and calculation
95 of 100 predictions are correct, so accuracy is 95%.
Class-specific recalls are 0 and 1, giving BA = 50%.
The high overall fraction comes entirely from the large negative class.
Transfer · Challenge
A matrix has TP = 32, FN = 8, TN = 180 and FP = 20. Does balanced accuracy change if actual and predicted labels are both relabelled so the former negative class becomes positive?
Show hint
The two class-specific rates exchange roles.
Learning goal: Check the effect of consistently relabelling both classes.
Show solution and calculation
Initially BA = (32/40 + 180/200)/2 = 0.85.
After consistent relabelling, TP′ = 180, FN′ = 20, TN′ = 32 and FP′ = 8.
The rates become 0.90 and 0.80, retaining the same mean 0.85.
Check your understanding with the formula’s reference test.
8 test questions · English materials
Already have an account? Sign in for the testAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Sources for this explanation
Quanta · Updated November 1, 2026
- scikit-learn documentation: balanced_accuracy_score, definition and adjusted option
- scikit-learn User Guide: Balanced accuracy score, binary formula and class-balanced weighting
Editorial responsibility: Quanta Study editorial team
Review scope
This explanation, 2 worked examples and 5 exercises are available in German and English. Structure, source references and mathematical notation undergo automated checks. Calculations, model assumptions and both language versions receive a separate AI review.
An independent, named human subject review has not yet been documented. Our exercise numbers are worked examples, rather than measurements published by the cited sources.
Editorial responsibility, sources and methodsChange history
- Explained class-wise weighting with two original examples, five exercises and distinctions from accuracy and chance adjustment.
Cite this reference page
Quanta. Balanced accuracy. Updated November 1, 2026. https://quanta-study.de/en/formula-sheet/balanced-accuracy
When citing a specific scientific statement, also cite the specialist source linked to that statement.