Skip to contents

For ordinal forecasts, the default scoring rules are:

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 is NULL (the default), all possible scoring rules are returned.

exclude

A character vector of scoring rules to exclude from the list. If select is not NULL, this argument is ignored.

...

unused

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>
#>