Get default metrics for nominal forecasts
Source:R/class-forecast-ordinal.R
get_metrics.forecast_ordinal.Rd
For ordinal forecasts, the default scoring rules are:
"log_score" =
logs_categorical()
"rps" =
rps_ordinal()
Usage
# S3 method for class 'forecast_ordinal'
get_metrics(x, select = NULL, exclude = NULL, ...)
Arguments
- x
A forecast object (a validated data.table with predicted and observed values, see
as_forecast_binary()
).- select
A character vector of scoring rules to select from the list. If
select
isNULL
(the default), all possible scoring rules are returned.- exclude
A character vector of scoring rules to exclude from the list. If
select
is notNULL
, this argument is ignored.- ...
unused
See also
Other get_metrics functions:
get_metrics()
,
get_metrics.forecast_binary()
,
get_metrics.forecast_nominal()
,
get_metrics.forecast_point()
,
get_metrics.forecast_quantile()
,
get_metrics.forecast_sample()
,
get_metrics.scores()
Examples
get_metrics(example_ordinal)
#> $log_score
#> function (observed, predicted, predicted_label)
#> {
#> assert_input_categorical(observed, predicted, predicted_label)
#> n <- length(observed)
#> if (n == 1) {
#> predicted <- matrix(predicted, nrow = 1)
#> }
#> observed_indices <- as.numeric(observed)
#> pred_for_observed <- predicted[cbind(1:n, observed_indices)]
#> logs <- -log(pred_for_observed)
#> return(logs)
#> }
#> <bytecode: 0x55993578b3f8>
#> <environment: namespace:scoringutils>
#>
#> $rps
#> function (observed, predicted, predicted_label)
#> {
#> assert_input_ordinal(observed, predicted, predicted_label)
#> n <- length(observed)
#> if (n == 1) {
#> predicted <- matrix(predicted, nrow = 1)
#> }
#> correct_order <- as.numeric(predicted_label)
#> ordered_predicted <- predicted[, correct_order]
#> rps <- scoringRules::rps_probs(as.numeric(observed), ordered_predicted)
#> return(rps)
#> }
#> <bytecode: 0x55993a4efc78>
#> <environment: namespace:scoringutils>
#>