Per-class Dice and Jaccard (IoU) plus an overall accuracy and Cohen's kappa,
comparing a reference mask a against a second mask b (e.g. an annotatR
mask against a .npy ground truth, or two annotators). Classes are matched by
integer value, so both masks must use the same class codebook.
Usage
at_mask_agreement(
a,
b,
background = 0L,
labels = NULL,
call = rlang::caller_env()
)Arguments
- a
Reference
annot_maskor integer matrix.- b
Comparison
annot_maskor integer matrix, same dimensions asa.- background
Integer value treated as unlabeled/background and excluded from the per-class rows (still counted for overall accuracy/kappa). Default
0.- labels
Optional named vector or legend tibble (
value,label) overriding the reference legend for class labels.- call
The calling environment, for error reporting.
Value
A tibble::tibble with one row per class: value, label,
n_true, n_pred, tp, fp, fn, dice, iou. The overall
attribute is a list of accuracy, kappa, mean_dice, mean_iou, and
n_px.
Examples
m <- at_mask(at_example_project(), "multiclass")
ag <- at_mask_agreement(m, m)
attr(ag, "overall")$kappa
#> [1] 1