summarise_scores: Summarise scores as produced by 'score()'

View source: R/summarise_scores.R

summarise_scoresR Documentation

Summarise scores as produced by score()

Description

Summarise scores as produced by score().

summarise_scores relies on a way to identify the names of the scores and distinguish them from columns that denote the unit of a single forecast. Internally, this is done via a stored attribute, metrics that stores the names of the scores. This means, however, that you need to be careful with renaming scores after they have been produced by score(). If you do, you also have to manually update the attribute by calling attr(scores, "metrics") <- new_names.

Usage

summarise_scores(scores, by = "model", across = NULL, fun = mean, ...)

summarize_scores(scores, by = "model", across = NULL, fun = mean, ...)

Arguments

scores

An object of class scores (a data.table with scores and an additional attribute metrics as produced by score()).

by

Character vector with column names to summarise scores by. Default is model, meaning that there will be one score per model in the output.

across

Character vector with column names to summarise scores across (meaning that the specified columns will be dropped). This is an alternative to specifying by directly. If across is set, by will be ignored. If across is NULL (default), then by will be used.

fun

A function used for summarising scores. Default is mean().

...

Additional parameters that can be passed to the summary function provided to fun. For more information see the documentation of the respective function.

Value

A data.table with summarised scores. Scores are summarised according to the names of the columns of the original data specified in by or across using the fun passed to summarise_scores().

Examples


library(magrittr) # pipe operator
scores <- score(as_forecast(example_sample_continuous))

# get scores by model
summarise_scores(scores,by = "model")

# get scores by model and target type
summarise_scores(scores, by = c("model", "target_type"))

# Get scores summarised across horizon, forecast date, and target end date
summarise_scores(
 scores, across = c("horizon", "forecast_date", "target_end_date")
)

# get standard deviation
summarise_scores(scores, by = "model", fun = sd)

# round digits
summarise_scores(scores,by = "model") %>%
  summarise_scores(fun = signif, digits = 2)

epiforecasts/scoringutils documentation built on April 23, 2024, 4:56 p.m.