From ec9face02fdd9aeb699d770b493dcf9af9121ff0 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Thu, 31 Oct 2024 10:18:27 +0100 Subject: [PATCH 1/2] update docs --- R/class-forecast.R | 5 ++++- R/score.R | 5 ++++- README.Rmd | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/R/class-forecast.R b/R/class-forecast.R index 6992e0a0..62998deb 100644 --- a/R/class-forecast.R +++ b/R/class-forecast.R @@ -75,10 +75,13 @@ assert_forecast.default <- function( forecast, forecast_type = NULL, verbose = TRUE, ... ) { cli_abort( + #nolint start: keyword_quote_linter c( "!" = "The input needs to be a valid forecast object.", - "i" = "Please convert to `forecast` object first (see {.fn as_forecast})." # nolint + "i" = "Please convert to `forecast` object first by calling the + appropriate {.fn as_forecast_} function)." ) + #nolint end ) } diff --git a/R/score.R b/R/score.R index 00300d31..da19c515 100644 --- a/R/score.R +++ b/R/score.R @@ -100,10 +100,13 @@ score <- function(forecast, metrics, ...) { #' @export score.default <- function(forecast, metrics, ...) { cli_abort( + #nolint start: keyword_quote_linter c( "!" = "The input needs to be a valid forecast object.", - "i" = "Please convert to `forecast` object first (see {.fn as_forecast})." # nolint + "i" = "Please convert to `forecast` object first by calling the + appropriate {.fn as_forecast_} function)." ) + #nolint end ) } diff --git a/README.Rmd b/README.Rmd index a73c86a4..ba111ebc 100644 --- a/README.Rmd +++ b/README.Rmd @@ -87,12 +87,13 @@ remotes::install_github("epiforecasts/scoringutils", dependencies = TRUE) - `point`: a forecast for a continuous or discrete outcome variable that is represented by a single number. - `quantile`: a probabilistic forecast for a continuous or discrete outcome variable, with the forecast distribution represented by a set of predictive quantiles. - `sample`: a probabilistic forecast for a continuous or discrete outcome variable, with the forecast represented by a finite set of samples drawn from the predictive distribution. +- `nominal` categorical forecast with unordered outcome possibilities (generalisation of binary forecasts to multiple outcomes) ### Input formats and input validation -The expected input format is generally a `data.frame` (or similar) with required columns `observed`, `predicted`, and `model` that holds the forecasts and observed values. Exact requirements depend on the forecast type. For more information, have a look at the [paper](https://drive.google.com/file/d/1URaMsXmHJ1twpLpMl1sl2HW4lPuUycoj/view?usp=drive_link), call `?as_forecast()`, or have a look at the example data provided in the package (`example_binary`, `example_point`, `example_quantile`, `example_sample_continuous`, `example_sample_discrete`). +The expected input format is generally a `data.frame` (or similar) with required columns `observed`, and `predicted` that holds the forecasts and observed values. Exact requirements depend on the forecast type. For more information, have a look at the [paper](https://drive.google.com/file/d/1URaMsXmHJ1twpLpMl1sl2HW4lPuUycoj/view?usp=drive_link), call `?as_forecast_binary`, `?as_forecast_quantile` etc., or have a look at the example data provided in the package (`example_binary`, `example_point`, `example_quantile`, `example_sample_continuous`, `example_sample_discrete`, `example_nominal`). -Before scoring, input data needs to be validated and transformed into a forecast object using the function `as_forecast()`. +Before scoring, input data needs to be validated and transformed into a forecast object using one of the `as_forecast_()` functions. ```{r} forecast_quantile <- example_quantile |> From 8702288e2842ddf1a96f69693daf4130c1f41de7 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Thu, 31 Oct 2024 10:28:54 +0100 Subject: [PATCH 2/2] update news file --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index a96c9bac..67b2fd4e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,7 +11,7 @@ of our [original](https://doi.org/10.48550/arXiv.2205.07090) `scoringutils` pape ### `score()` - The main function of the package is still the function `score()`. However, we reworked the function and updated and clarified its input requirements. - - The previous columns "true_value" and "prediction" were renamed. `score()` now requires columns called "observed" and "predicted" and "model". The column `quantile` was renamed to `quantile_level` and `sample` was renamed to `sample_id` + - The previous columns "true_value" and "prediction" were renamed. `score()` now requires columns called "observed" and "predicted" (some functions still assume the existence of a `model` column as default but this is not a strict requirement). The column `quantile` was renamed to `quantile_level` and `sample` was renamed to `sample_id` - `score()` is now a generic. It has S3 methods for the classes `forecast_point`, `forecast_binary`, `forecast_quantile`, `forecast_sample`, and `forecast_nominal`, which correspond to the different forecast types that can be scored with `scoringutils`. - `score()` now calls `na.omit()` on the data, instead of only removing rows with missing values in the columns `observed` and `predicted`. This is because `NA` values in other columns can also mess up e.g. grouping of forecasts according to the unit of a single forecast. - `score()` and many other functions now require a validated `forecast` object. `forecast` objects can be created using the functions `as_forecast_point()`, `as_forecast_binary()`, `as_forecast_quantile()`, and `as_forecast_sample()` (which replace the previous `check_forecast()`). A forecast object is a data.table with class `forecast` and an additional class corresponding to the forecast type (e.g. `forecast_quantile`).