Skip to contents

Create summary data frame for confidence predictions over 1 or several state files or a data frame. Columns in file or data frame should be confidence predictions for one class, i.e. each rows should sum to 1 and have nonnegative entries. Output data frame contains average confidence scores, max score and percentage of votes for each class.

Usage

summarize_states(
  states_path = NULL,
  label_names = NULL,
  file_type = "h5",
  df = NULL
)

Arguments

states_path

Folder containing state files or a single file with same ending as file_type.

label_names

Names of predicted classes.

file_type

"h5" or "csv".

df

A states data frame. Ignore states_dir argument if not NULL.

Value

A data frame of predictions summaries.

Examples

m <- c(0.9,  0.1, 0.2, 0.01,
       0.05, 0.7, 0.2, 0,
       0.05, 0.2, 0.6, 0.99) %>% matrix(ncol = 3)

label_names <- paste0("class_", 1:3)
df <- as.data.frame(m)
pred_summary <- summarize_states(label_names = label_names, df = df)
pred_summary
#>    file_name mean_conf_class_1 mean_conf_class_2 mean_conf_class_3
#>       <lgcl>             <num>             <num>             <num>
#> 1:        NA            0.3025            0.2375              0.46
#>    max_conf_class_1 max_conf_class_2 max_conf_class_3 vote_perc_class_1
#>               <num>            <num>            <num>             <num>
#> 1:              0.9              0.7             0.99              0.25
#>    vote_perc_class_2 vote_perc_class_3 mean_prediction max_prediction
#>                <num>             <num>          <char>         <char>
#> 1:              0.25               0.5         class_3        class_3
#>    vote_prediction num_prediction
#>             <char>          <int>
#> 1:         class_3              4