Function to check a set of predictions for a set of expected predictions (e.g. targets, locations)

verify_expected(x, expected_list, return_df = FALSE, print_output = !return_df)

Arguments

x

predx_df

expected_list

list of lists (see Note)

return_df

if TRUE (default is FALSE) will return a list of missing predictions

print_output

if TRUE (default) prints results

Value

If any predictions in expected_list are not found or if additional predictions are found, the function will print the missing and/or additional rows (print_out = TRUE) or return a data frame with a status designation for each missing and/or additional row (return_df = TRUE).

Note

expected_list is a two-level list of sets of expected predictions. The lower level (e.g. expected_list[[1]]) is a list of named character vectors with specific expected predictions. The names should match column names in x. The function checks that all combinations of those elements are present in x. A named vector predx_class may be used to check predx types.

Examples

predx_demo <- as.predx_df(list( location = c("Mercury", "Venus", "Earth"), target = "habitability", predx = list(Binary(1e-4), Binary(1e-4), Binary(1)) )) expected_demo <- list( list( location = c("Mercury", "Venus", "Earth"), target = "habitability", predx_class = "Binary" ) ) expected_demo2 <- list( list( location = c("Mercury", "Mars"), target = "habitability", predx_class = "Binary" ) ) verify_expected(predx_demo, expected_demo)
#> All expected predictions found.
verify_expected(predx_demo, expected_demo2)
#> [1] "The following predictions are missing:" #> # A tibble: 1 x 3 #> location target predx_class #> <chr> <chr> <chr> #> 1 Mars habitability Binary #> [1] "The following additional predictions were found:" #> # A tibble: 2 x 3 #> location target predx_class #> <chr> <chr> <chr> #> 1 Venus habitability Binary #> 2 Earth habitability Binary