Consider G-mean over Accuracy as Classification Score

Piotr Włodarek
1 min readJul 28, 2023

--

Deficiencies of accuracy score are well known. It is simple but often misleading metric. Accuracy answers the question how often a model is correct (say model is correct 82% of the time). But it fails to capture practical implications of class imbalance.

If you want to reliably capture classification performance in a single metric then consider using G-mean instead.

G-mean = (sensitivity * specificity)^1/2

It’s a square root of the product of sensitivity and specificity.

In a nice symmetrical way it captures both sensitivity on positive class and sensitivity on negative class while giving them equal weights, contrary to “global” accuracy. With accuracy the weights are somewhat incidental (equal to proportions of observations in the classes).

How to practically go about it? In case of scikit-learn you pass a custom scorer. Simple example in this StackOverflow thread.

Another alternative to plain accuracy is balanced accuracy, this scorer is offered by scikit-learn out of the box.

--

--

No responses yet