Balanced Accuracy

Machine Learning
Introduced by
Brodersen, Ong, Stephan, and Buhmann
Year
2010
Type
Evaluation metric
Family
Classification Metric

What does it do?

Balanced accuracy is the mean of the recall values computed separately for each class.

Because each class contributes equally, the score does not depend on how frequent each class is in the dataset. For binary tasks it equals the average of sensitivity and specificity.

The intuition behind the method

Overall accuracy counts every instance equally, so a classifier that mostly predicts the majority class can score well while missing most minority cases. Balanced accuracy avoids this by measuring how well the classifier recovers each class and then averaging those per-class recalls. A model that always predicts the majority class gets a recall of 1 for that class and 0 for the minority class, so its balanced accuracy is 0.5 for a binary task. For binary classification the score is the mean of sensitivity (true positive rate) and specificity (true negative rate). The same definition extends to more than two classes by averaging all per-class recalls.

History

Brodersen, Ong, Stephan, and Buhmann (2010) studied the balanced accuracy and proposed estimating its posterior distribution, which gives confidence intervals that averaging fold accuracies does not. Their work was motivated by the optimistic estimates that arise when a biased classifier is tested on an imbalanced dataset.

When to use it

Choose balanced accuracy when the classes are imbalanced and the performance on the rare class matters as much as performance on the common class, and when the cost of each type of error is roughly comparable. It is a sensible summary for comparing models on a skewed test set before the operating threshold is fixed. Do not rely on it alone when false positives and false negatives have clearly different costs, or when the practical question is how many predicted positives are correct (precision), because the metric does not use precision. On a balanced dataset it adds little over plain accuracy. Brodersen et al. (2010) note that averaging accuracies across cross-validation folds can give an optimistic estimate when a biased classifier is tested on an imbalanced dataset. For that setting they propose estimating the posterior distribution of the balanced accuracy in place of the conventional accuracy point estimate.

Limitations and considerations

  • Class prevalence is removed from the score, so it does not describe how often a positive prediction is correct in a population where the rare class is very rare; precision can be poor even when balanced accuracy is high.
  • The average can hide weak performance on one class. A high mean of per-class recalls does not guarantee that every class meets a required minimum.
  • Equal weighting of classes is itself an assumption. If the application values some classes or error types more than others, the unweighted mean does not reflect that priority.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Each class contributes equally to the score, so a classifier cannot obtain a high value by predicting only the majority class; that strategy yields 0.5 for a binary task.
  • For binary problems the score has a direct reading as the mean of sensitivity and specificity, so the two components can be inspected separately.
  • The same definition extends to multiple classes by averaging all per-class recalls, without changing the interpretation.
  • The metric is computed from the confusion matrix at a fixed decision threshold, so it needs no modelling assumptions beyond the labelled test set.

Applications

  • Screening tasks for rare conditions, where recall for the condition class must be reported next to recall for the healthy class.
  • Fraud or intrusion detection, where the positive class is small and its recall is evaluated alongside the recall for legitimate cases.
  • Model comparison on skewed test sets, before an operating threshold and error costs have been set.

How it works

How it works

1

For each class separately, compute recall (sensitivity): the proportion of the instances truly belonging to that class that the classifier predicted as that class. Each class must have at least one test instance for its recall to be defined.

Formula
\mathrm{Recall}_k = \frac{TP_k}{TP_k + FN_k}
2

Average the per-class recall values with equal weight. For binary classification this is (sensitivity + specificity) / 2, where specificity is the proportion of true negatives correctly identified (one minus the false positive rate).

Formula
\mathrm{BA}_{\text{binary}} = \frac{\mathrm{TPR} + \mathrm{TNR}}{2}, \quad \mathrm{TPR} = \frac{TP}{TP+FN}, \quad \mathrm{TNR} = \frac{TN}{TN+FP}
3

A balanced accuracy of 1.0 indicates perfect classification on all classes. Values less than random guessing (e.g., 0.5 for binary classification) suggest the model performs worse than chance on average. A balanced accuracy computed on one test set is a point estimate. Brodersen et al. (2010) show that it can be replaced by an estimate of its posterior distribution, which yields confidence intervals that averaging fold accuracies does not. Report such an interval alongside the score when models are compared.

Common pitfalls

  • Treating balanced accuracy as a complete answer to imbalance without considering the cost of each error type in the application.
  • Combining balanced accuracy with class-weighted training. Both address class frequency, so check whether the combination is intended and inspect the per-class recalls rather than assuming the imbalance was handled once.
  • Reporting only the aggregate score and not the per-class recalls, which hides which class is being missed.
  • Using balanced accuracy on a dataset whose classes are already roughly equal, where plain accuracy gives essentially the same ranking and is easier to explain.
  • Averaging over a class with zero test support. Its per-class recall is undefined: in the library example the balanced accuracy for minor_disease is NA because its prevalence in the test set is 0. Report that class as undefined, state explicitly that the average covers fewer classes, or redesign the split so every class is represented. Do not present a balanced accuracy that silently omits a class.

Frequently asked questions

How does balanced accuracy differ from accuracy in imbalanced datasets?

On imbalanced datasets, overall accuracy can be high while minority class performance is poor, because the majority class dominates the count. Balanced accuracy gives each class the same weight, so a model that performs poorly on the minority class receives a lower score. A model that predicts every instance as the majority class reaches an accuracy equal to the majority share of the data (90% when that share is 90%), but its balanced accuracy in a binary task is 0.5.

Is balanced accuracy the same as averaging precision and recall?

No. Balanced accuracy is the average of the per-class recalls. For binary classification it equals the mean of sensitivity and specificity, where specificity is one minus the false positive rate. Averaging precision and recall combines two different quantities and gives a different score.

When should I use balanced accuracy instead of F1-score or ROC-AUC?

ROC-AUC evaluates how well the scores rank instances across all decision thresholds, while balanced accuracy evaluates the classifier at one fixed threshold. F1-score focuses on the positive class and ignores true negatives, whereas balanced accuracy uses the recall of both classes. Balanced accuracy suits cases where both classes matter equally and the threshold is already fixed; F1-score suits cases where precision and recall of the positive class matter most.

Related methods

Sources

  1. Brodersen, K. H., Ong, C. S., Stephan, K. E., & Buhmann, J. M. (2010). The balanced accuracy and its posterior distribution. 20th International Conference on Pattern Recognition (ICPR), 3121-3124.

    Open DOI reference
  2. Powers, D. M. (2011). Evaluation: From Precision, Recall and F-Measure to ROC, Informedness, Markedness and Correlation. Journal of Machine Learning Technologies, 2(1), 37-63.

    Open publication reference