Computes balanced accuracy by averaging class-specific mean accuracy, giving each observed class equal weight regardless of class frequency.
Arguments
- y
An integer vector of observed class labels. Code it 0 or 1 when
mupredis a matrix, and 1 to K whenmupredis a 3-D array.- mupred
A numeric array of posterior predictive means. For binary outcomes use a draws x observations matrix. For multiclass outcomes use a draws x observations x categories array.
- log_weights
Optional numeric matrix of unnormalized log-importance weights with dimensions \(S \times n\). Weights are column-normalized before computing each per-observation contribution.
- pointwise
Optional numeric vector of precomputed pointwise contributions \(acc_i / (K n_{y_i})\), as stored by
measure_bacc(). If provided,mupredandlog_weightsare ignored.yis always required, because it defines the classes.
Value
An object of class "measure": a list with:
estimatesA 1 \(\times\) 2 matrix. The row is named after the measure, the columns are
EstimateandSE(standard error).pointwiseAn \(n \times 1\) matrix of per-observation values. The column is named after the measure.
extraOptional. Auxiliary data for the standard error of a difference. Most measures do not set it.
Attributes measure (i.e., measure name) and dims (draws \(\times\)
observations) are also set. Use print() for a readable summary.