Wrapper for creating custom metric functions with consistent interface and error handling.
Examples
# Custom length comparison
length_metric <- metric_custom(function(pred, exp) {
nchar(as.character(pred)) == nchar(as.character(exp))
}, name = "length_match")
# Custom scoring function
score_metric <- metric_custom(function(pred, exp) {
# Return value between 0 and 1
min(nchar(pred) / nchar(exp), 1)
})
