set_forecast_unit {scoringutils} | R Documentation |
Set unit of a single forecast manually
Description
Helper function to set the unit of a single forecast (i.e. the
combination of columns that uniquely define a single forecast) manually.
This simple function keeps the columns specified in forecast_unit
(plus
additional protected columns, e.g. for true values, predictions or quantile
levels) and removes duplicate rows.
If not done manually, scoringutils
attempts to determine the unit
of a single forecast automatically by simply assuming that all column names
are relevant to determine the forecast unit. This may lead to unexpected
behaviour, so setting the forecast unit explicitly can help make the code
easier to debug and easier to read. When used as part of a workflow,
set_forecast_unit()
can be directly piped into check_forecasts()
to
check everything is in order.
Usage
set_forecast_unit(data, forecast_unit)
Arguments
data |
A data.frame or data.table with the predictions and observations.
For scoring using
For scoring integer and continuous forecasts a
For scoring predictions in a quantile-format forecast you should provide
a column called
In addition a You can check the format of your data using |
forecast_unit |
Character vector with the names of the columns that uniquely identify a single forecast. |
Value
A data.table with only those columns kept that are relevant to scoring or denote the unit of a single forecast as specified by the user.
Examples
set_forecast_unit(
example_quantile,
c("location", "target_end_date", "target_type", "horizon", "model")
)