Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Ray <[email protected]>
  • Loading branch information
nikosbosse and elray1 authored Dec 7, 2024
1 parent 34fddf7 commit a27b87a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion R/class-forecast-ordinal.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ score.forecast_ordinal <- function(forecast, metrics = get_metrics(forecast), ..
#' Get default metrics for nominal forecasts
#' @inheritParams get_metrics.forecast_binary
#' @description
#' For nominal forecasts, the default scoring rule is:
#' For ordinal forecasts, the default scoring rules are:
#' - "log_score" = [logs_nominal()]
#' - "rps" = [rps_ordinal()]
#' @export
Expand Down
13 changes: 7 additions & 6 deletions R/metrics-ordinal.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ logs_ordinal <- function(observed, predicted, predicted_label) {
#' The Ranked Probability Score (RPS) measures the difference between the predicted
#' and observed cumulative distribution functions. It is a proper scoring rule that
#' takes the ordering of categories into account. Small values are better
#' (best is zero, worst is 1).
#' (best is zero, worst is N - 1 where N is the number of categories).
#' @param observed A factor of length n with N levels holding the observed
#' values.
#' @param predicted nxN matrix of predictive probabilities, n (number of rows)
Expand All @@ -133,14 +133,15 @@ logs_ordinal <- function(observed, predicted, predicted_label) {
#' @keywords metric
#' @family scoring functions
#' @examples
#' factor_levels <- c("one", "three", "two")
#' factor_levels <- c("one", "two", "three")
#' predicted_label <- factor(factor_levels, levels = factor_levels, ordered = TRUE)
#' observed <- factor(c("three", "three", "two"), levels = factor_levels, ordered = TRUE)
#' predicted <- matrix(
#' c(0.8, 0.1, 0.4,
#' 0.1, 0.2, 0.4,
#' 0.1, 0.7, 0.2),
#' nrow = 3
#' c(0.8, 0.1, 0.1,
#' 0.1, 0.2, 0.7,
#' 0.4, 0.4, 0.2),
#' nrow = 3,
#' byrow = TRUE
#' )
#' rps_ordinal(observed, predicted, predicted_label)
rps_ordinal <- function(observed, predicted, predicted_label) {
Expand Down

0 comments on commit a27b87a

Please sign in to comment.