metric_field_match() makes a metric that compares several fields of the
prediction with the columns of the same names in the expected row.
Values must be exactly equal (numbers may differ in storage type only).
Value
A function function(prediction, expected) returning TRUE or
FALSE. A field missing from either side is an error.
Examples
both <- metric_field_match(c("city", "country"))
row <- data.frame(question = "Where is the Louvre?", city = "Paris", country = "France")
both(list(city = "Paris", country = "France"), row)
#> [1] TRUE
both(list(city = "Paris", country = "Belgium"), row)
#> [1] FALSE
either <- metric_field_match(c("city", "country"), require_all = FALSE)
either(list(city = "Paris", country = "Belgium"), row)
#> [1] TRUE