Notes

Balanced Accuracy

When one class is rare—fraud, disease, churn—plain accuracy can look great even if your model barely finds the cases you care about. Balanced accuracy fixes that by giving each class an equal “vote” in the final score.

What it measures

Balanced accuracy is the average of how well the model recognizes each class. In binary classification, it’s the mean of:

  • Sensitivity / Recall / True Positive Rate (TPR): among actual positives, how many you correctly catch.
  • Specificity / True Negative Rate (TNR): among actual negatives, how many you correctly reject.

So, balanced accuracy = (TPR + TNR) / 2. For multi-class problems, it generalizes to the average recall computed separately for each class.

Why it matters for imbalanced data

Imagine 1% of transactions are fraud. A model that predicts “not fraud” every time gets 99% accuracy, but its TPR is 0%. Balanced accuracy would be (0 + 1)/2 = 0.5, correctly signaling “this model is useless for fraud.” This makes balanced accuracy a good default metric when class sizes are skewed and you want a single number that reflects performance on both the minority and majority classes.

How it’s used in practice

You’ll see it in model selection and cross-validation scoring, for example in scikit-learn:

from sklearn.metrics import balanced_accuracy_score
score = balanced_accuracy_score(y_true, y_pred)

It’s threshold-dependent (it evaluates a specific set of predicted labels), so it complements threshold-free views like ROC-AUC when you’re tuning decision cutoffs.

Balanced accuracy is a classification metric defined as the average of per-class recall, typically (sensitivity + specificity)/2 in binary problems and the mean recall across classes in multiclass settings. It gives each class equal weight regardless of prevalence, unlike raw accuracy which can be dominated by the majority class. It matters because it provides a fairer, more diagnostic evaluation of models on imbalanced datasets.

Imagine you’re grading a security guard. If 99 people are harmless and 1 is a threat, the guard could wave everyone through and still be “99% accurate” while missing the one case that matters. Balanced Accuracy is a fairer report card for situations like this.

It measures how well a model does on each group separately (for example, “spam” and “not spam,” or “disease” and “no disease”) and then gives those groups equal weight. That way, doing well on the common cases doesn’t hide poor performance on the rare but important ones.