get_metrics.scores: Get names of the metrics that were used for scoring

View source: R/class-scores.R

get_metrics.scoresR Documentation

Get names of the metrics that were used for scoring

Description

When applying a scoring rule via score(), the names of the scoring rules become column names of the resulting data.table. In addition, an attribute metrics will be added to the output, holding the names of the scores as a vector.

This is done so that functions like get_forecast_unit() or summarise_scores() can still identify which columns are part of the forecast unit and which hold a score.

get_metrics() accesses and returns the metrics attribute. If there is no attribute, the function will return NULL (or, if error = TRUE will produce an error instead). In addition, it checks the column names of the input for consistency with the data stored in the metrics attribute.

Handling a missing or inconsistent metrics attribute:

If the metrics attribute is missing or is not consistent with the column names of the data.table, you can either

  • run score() again, specifying names for the scoring rules manually, or

  • add/update the attribute manually using attr(scores, "metrics") <- c("names", "of", "your", "scores") (the order does not matter).

Usage

## S3 method for class 'scores'
get_metrics(x, error = FALSE, ...)

Arguments

x

A scores object, (a data.table with an attribute metrics as produced by score()).

error

Throw an error if there is no attribute called metrics? Default is FALSE.

...

unused

Value

Character vector with the names of the scoring rules that were used for scoring.

See Also

Other get_metrics functions: get_metrics(), get_metrics.forecast_binary(), get_metrics.forecast_nominal(), get_metrics.forecast_ordinal(), get_metrics.forecast_point(), get_metrics.forecast_quantile(), get_metrics.forecast_sample()


epiforecasts/scoringutils documentation built on Dec. 11, 2024, 11:12 a.m.