Computes primary and failure-mode metrics for label repair. Returned measures include recovery (accuracy and adjusted Rand index), class imbalance robustness (macro and worst recall), boundary/sparse reliability, and damage.
Usage
evaluate_spatial_refinement(
truth,
initial,
refined,
boundary = NULL,
regions = NULL,
sparse = NULL,
elapsed = NA_real_,
method = NULL
)Arguments
- truth
Reference assignments.
- initial
Initial noisy assignments.
- refined
Assignments returned by a refinement method.
- boundary
Optional logical vector marking boundary observations.
- regions
Optional region identifier. The least and most frequent regions define sparse- and dense-region accuracy when `sparse` is omitted.
- sparse
Optional logical vector marking sparse-region observations.
- elapsed
Optional elapsed runtime in seconds.
- method
Optional method name included in the returned row.
Details
`correction_recall` is the fraction of initially incorrect labels that are repaired. `damage_rate` is the fraction of initially correct labels that are flipped to an incorrect label. `changed_precision` is the fraction of modified sites that are correct after refinement. Empty strata are reported as `NA` rather than imputed as zero. Adjusted Rand index is calculated directly from the vectors and does not require an external package.
Examples
truth <- factor(c("A", "A", "B", "B"))
initial <- factor(c("A", "B", "B", "A"))
refined <- truth
evaluate_spatial_refinement(truth, initial, refined)
#> n classes initial_accuracy accuracy accuracy_gain error_reduction ari
#> 1 4 2 0.5 1 0.5 1 1
#> macro_recall worst_recall sparse_region_accuracy dense_region_accuracy
#> 1 1 1 NA NA
#> boundary_accuracy interior_accuracy correction_recall damage_rate
#> 1 NA NA 1 0
#> changed_precision changed_fraction unresolved_fraction seconds
#> 1 1 0.5 0 NA