Computes pointwise and average classification accuracy for binary or
multiclass outcomes. The class probabilities are first averaged over the
draws, using log_weights if given. For binary outcomes, the averaged
probability is thresholded at 0.5. For multiclass outcomes, the predicted
class is the most likely category of the averaged probabilities, via
which.max().
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 accuracy contributions. If provided,
y,mupred, andlog_weightsare ignored.
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.