customise_metric: Customises a metric function with additional arguments.

View source: R/default-scoring-rules.R

customise_metricR Documentation

Customises a metric function with additional arguments.

Description

This function takes a metric function and additional arguments, and returns a new function that includes the additional arguments when calling the original metric function.

This is the expected way to pass additional arguments to a metric when evaluating a forecast using score(): To evaluate a forecast using a metric with an additional argument, you need to create a custom version of the scoring function with the argument included. You then need to create an updated version of the list of scoring functions that includes your customised metric and pass this to score().

Usage

customise_metric(metric, ...)

customize_metric(metric, ...)

Arguments

metric

The metric function to be customised.

...

Additional arguments to be included when calling the metric function.

Value

A customised metric function.

Examples

# Create a customised metric function
custom_metric <- customise_metric(mean, na.rm = TRUE)

# Use the customised metric function
values <- c(1, 2, NA, 4, 5)
custom_metric(values)

# Updating metrics list to calculate 70% coverage in `score()`
interval_coverage_70 <- customise_metric(
  interval_coverage, interval_range = 70
)
updated_metrics <- c(
  metrics_quantile(),
  "interval_coverage_70" = interval_coverage_70
)
score(
  as_forecast(example_quantile),
  metrics = updated_metrics
)



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