Skip to contents

Measure to compare true observed labels with predicted labels in multiclass classification tasks.

Details

The Balanced Accuracy computes the weighted balanced accuracy, suitable for imbalanced data sets. It is defined analogously to the definition in sklearn.

First, all sample weights \(w_i\) are normalized per class so that each class has the same influence: $$ \hat{w}_i = \frac{w_i}{\sum_{j=1}^n w_j \cdot \mathbf{1}(t_j = t_i)}. $$ The Balanced Accuracy is then calculated as $$ \frac{1}{\sum_{i=1}^n \hat{w}_i} \sum_{i=1}^n \hat{w}_i \cdot \mathbf{1}(r_i = t_i). $$ This definition is equivalent to acc() with class-balanced sample weights.

Note

The score function calls mlr3measures::bacc() from package mlr3measures.

If the measure is undefined for the input, NaN is returned. This can be customized by setting the field na_value.

Dictionary

This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():

mlr_measures$get("classif.bacc")
msr("classif.bacc")

Parameters

Empty ParamSet

Meta Information

  • Type: "classif"

  • Range: \([0, 1]\)

  • Minimize: FALSE

  • Required prediction: response