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

View source: R/get_-functions.R

get_metricsR 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 a function like get_forecast_unit() can still identify which columns are part of the forecast unit and which hold a score.

get_metrics() access and returns this attribute. If there is no attribute, the function will return NULL. Users can control whether the function should error instead via the error argument.

get_metrics() also checks whether the names of the scores stored in the attribute are column names of the data and will throw a warning if not. This can happen if you rename columns after scoring. You can either run score() again, specifying names for the scoring rules manually, or you can update the attribute manually using attr(scores, "metrics") <- c("names", "of", "your", "scores") (the order does not matter).

Usage

get_metrics(scores, error = FALSE)

Arguments

scores

A data.table with an attribute metrics.

error

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

Value

Character vector with the names of the scoring rules that were used for scoring or NULL if no scores were computed previously.


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