Computes the weighted balanced accuracy, suitable for imbalanced data sets. It is defined analogously to the definition in sklearn.

First, the sample weights $$w$$ are normalized per class: $$\hat{w}_i = \frac{w_i}{\sum_j 1(y_j = y_i) w_i}.$$ The balanced accuracy is calculated as $$\frac{1}{\sum_i \hat{w}_i} \sum_i 1(r_i = t_i) \hat{w}_i.$$

## 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("bacc")
msr("bacc")

## Meta Information

• Type: "classif"

• Range: $$[0, 1]$$

• Minimize: FALSE

• Required prediction: response