metric_threshold() wraps a metric so that it returns TRUE when the
score passes threshold and FALSE otherwise. Use it where a yes/no
judgement is needed, for example to count only answers with an F1 score
of at least 0.8 as correct.
Value
A metric returning TRUE or FALSE. If metric returns
feedback, the result is list(score = TRUE/FALSE, feedback = ). The
field attribute and trace-aware and feedback classes of metric are
kept.
Examples
f1 <- metric_f1(field = "answer")
good_enough <- metric_threshold(f1, threshold = 0.8)
row <- data.frame(question = "Where is the Louvre?", answer = "The Louvre is in Paris")
f1(list(answer = "In Paris"), row)
#> [1] 0.5714286
good_enough(list(answer = "In Paris"), row)
#> [1] FALSE
good_enough(list(answer = "The Louvre is in Paris, France"), row)
#> [1] TRUE