View source: R/default-scoring-rules.R
customise_metric | R Documentation |
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()
.
customise_metric(metric, ...)
customize_metric(metric, ...)
metric |
The metric function to be customised. |
... |
Additional arguments to be included when calling the metric function. |
A customised metric function.
# 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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.