Skip to content

Commit 2a7aee4

Browse files
authored
Fix bug in metric handling and add raw score to report (#937)
* Handle minimized metrics in generate_qc * Handle minimized metrics in render_report * Fix logo export for report * Adjust how metric direction is handled * Fix metric name mismatch * Add raw scores table to report
1 parent 0fc9241 commit 2a7aee4

File tree

1 file changed

+78
-5
lines changed

1 file changed

+78
-5
lines changed

src/reporting/render_report/report-template.qmd

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,15 +585,15 @@ method_details <- purrr::map_dfr(method_info, function(.method) {
585585
metric_details <- purrr::map_dfr(metric_info, function(.metric) {
586586
data.frame(
587587
metric = .metric$name,
588-
metric_label = .metric$label
588+
metric_label = .metric$label,
589+
metric_maximize = .metric$maximize
589590
)
590591
}) |>
591592
dplyr::arrange(metric)
592593
593-
metric_maximize <- purrr::map_lgl(metric_info, "maximize") |>
594-
purrr::set_names(metric_details$metric)
595-
596-
metric_reverse <- names(metric_maximize)[metric_maximize == FALSE]
594+
metric_reverse <- metric_details |>
595+
dplyr::filter(metric_maximize == FALSE) |>
596+
dplyr::pull(metric)
597597
598598
scores <- purrr::map_dfr(task_results$results, function(.result) {
599599
if (!.result$succeeded) {
@@ -1181,11 +1181,18 @@ funkyheatmap::funky_heatmap(
11811181

11821182
::: {.callout-note}
11831183
This table displays the scaled metric scores.
1184+
After scaling, higher scores are always better and any missing values are set to 0.
11841185
The "Overall" dataset gives the mean score across all of the actual datasets.
11851186

1187+
Raw scores are also provided to help with understanding any issues but should not be used to compare performance.
1188+
11861189
Sort and filter the table to check scores you are interested in.
11871190
:::
11881191

1192+
::: {.panel-tabset}
1193+
1194+
### Scaled scores {.unnumbered .unlisted}
1195+
11891196
```{r}
11901197
#| label: results-table
11911198
#| eval: !expr has_controls
@@ -1246,3 +1253,69 @@ reactable::reactable(
12461253
searchable = TRUE
12471254
)
12481255
```
1256+
1257+
### Raw scores {.unnumbered .unlisted}
1258+
1259+
```{r}
1260+
#| label: results-table-raw
1261+
#| eval: !expr has_controls
1262+
dataset_scores_raw <- complete_scores |>
1263+
dplyr::select(dataset, method, metric, value) |>
1264+
tidyr::pivot_wider(
1265+
names_from = metric,
1266+
values_from = value
1267+
)
1268+
1269+
table_data_raw <- dataset_scores_raw |>
1270+
dplyr::mutate(
1271+
dataset = factor(
1272+
dataset,
1273+
levels = dataset_details$dataset,
1274+
labels = dataset_details$dataset_label
1275+
),
1276+
method = factor(
1277+
method,
1278+
levels = method_details$method,
1279+
labels = method_details$method_label
1280+
)
1281+
) |>
1282+
dplyr::relocate(dataset, .after = method) |>
1283+
dplyr::arrange(dataset, method)
1284+
1285+
reactable::reactable(
1286+
table_data_raw,
1287+
1288+
columns = c(
1289+
list(
1290+
method = reactable::colDef(
1291+
name = "Method",
1292+
sticky = "left"
1293+
),
1294+
dataset = reactable::colDef(
1295+
name = "Dataset",
1296+
sticky = "left",
1297+
style = list(borderRight = "2px solid #999"),
1298+
headerStyle = list(borderRight = "2px solid #999")
1299+
)
1300+
),
1301+
purrr::map(metric_details$metric_label,
1302+
function(.metric_label) {
1303+
reactable::colDef(
1304+
name = .metric_label,
1305+
format = reactable::colFormat(digits = 3)
1306+
)
1307+
}
1308+
) |>
1309+
purrr::set_names(metric_details$metric)
1310+
),
1311+
1312+
highlight = TRUE,
1313+
striped = TRUE,
1314+
defaultPageSize = 25,
1315+
showPageSizeOptions = TRUE,
1316+
filterable = TRUE,
1317+
searchable = TRUE
1318+
)
1319+
```
1320+
1321+
:::

0 commit comments

Comments
 (0)