Skip to content

Commit

Permalink
Merge branch 'develop' into issue555
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs authored Jan 5, 2024
2 parents 15283dd + 8796b9f commit 3c57faf
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 136 deletions.
1 change: 1 addition & 0 deletions .github/workflows/render_readme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
push:
paths:
- 'README.Rmd'
- DESCRIPTION

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: scoringutils
Title: Utilities for Scoring and Assessing Predictions
Version: 1.2.2
Version: 1.2.2.9000
Language: en-GB
Authors@R: c(
person(given = "Nikos",
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ S3method(validate_forecast,forecast_binary)
S3method(validate_forecast,forecast_point)
S3method(validate_forecast,forecast_quantile)
S3method(validate_forecast,forecast_sample)
export(abs_error)
export(add_coverage)
export(add_pairwise_comparison)
export(ae_median_quantile)
Expand Down Expand Up @@ -68,7 +67,6 @@ export(score)
export(se_mean_sample)
export(select_rules)
export(set_forecast_unit)
export(squared_error)
export(summarise_scores)
export(summarize_scores)
export(theme_scoringutils)
Expand Down
8 changes: 5 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# scoringutils 2.0.0
# scoringutils 1.2.2.9000

This major update and addresses a variety of comments made by reviewers from the Journal of Statistical Software (see preprint of the manuscript [here](https://arxiv.org/abs/2205.07090)).

Expand Down Expand Up @@ -36,10 +36,12 @@ The update introduces breaking changes. If you want to keep using the older vers
- `plot_avail_forecasts()` was renamed `plot_forecast_counts()` in line with the change in the function name. The `x` argument no longer has a default value, as the value will depend on the data provided by the user.
- The deprecated `..density..` was replaced with `after_stat(density)` in ggplot calls.
- Files ending in ".Rda" were renamed to ".rds" where appropriate when used together with `saveRDS()` or `readRDS()`.
- `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()` 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.
- added documentation for the return value of `summarise_scores()`.
- Removed abs_error and squared_error from the package in favour of `Metrics::ae` and `Metrics::se`.
- Renamed `interval_coverage_quantile()` and `interval_coverage_dev_quantile()` to `interval_coverage()` and `interval_coverage_deviation()`, respectively. Removed `interval_coverage_sample()` as users are now expected to convert to a quantile format first before scoring.

- Added unit tests for `interval_coverage_quantile()` and `interval_coverage_dev_quantile()` in order to make sure that the functions provide the correct warnings when insufficient quantiles are provided.
- Documentation pkgdown pages are now created both for the stable and dev versions.

# scoringutils 1.2.2

Expand Down
52 changes: 0 additions & 52 deletions R/metrics-point.R

This file was deleted.

2 changes: 1 addition & 1 deletion R/metrics-quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ bias_quantile_single_vector <- function(observed, predicted, quantile, na.rm) {
#' `quantile`.
#' @inheritParams wis
#' @return numeric vector of length N with the absolute error of the median
#' @seealso [ae_median_sample()], [abs_error()]
#' @seealso [ae_median_sample()]
#' @importFrom stats median
#' @examples
#' observed <- rnorm(30, mean = 1:30)
Expand Down
3 changes: 1 addition & 2 deletions R/metrics-sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bias_sample <- function(observed, predicted) {
#' the number of data points and N (number of columns) the number of Monte
#' Carlo samples. Alternatively, `predicted` can just be a vector of size n.
#' @return vector with the scoring values
#' @seealso [ae_median_quantile()], [abs_error()]
#' @seealso [ae_median_quantile()]
#' @importFrom stats median
#' @examples
#' observed <- rnorm(30, mean = 1:30)
Expand Down Expand Up @@ -127,7 +127,6 @@ ae_median_sample <- function(observed, predicted) {
#' the number of data points and N (number of columns) the number of Monte
#' Carlo samples. Alternatively, `predicted` can just be a vector of size n.
#' @return vector with the scoring values
#' @seealso [squared_error()]
#' @examples
#' observed <- rnorm(30, mean = 1:30)
#' predicted_values <- matrix(rnorm(30, mean = 1:30))
Expand Down
25 changes: 25 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,31 @@ library(magrittr)
library(data.table)
library(ggplot2)
library(knitr)
## code to determine version inspired by [pkgdown:::dev_mode_auto()]
version <- packageVersion("scoringutils")
devel <- length(unclass(package_version(version))[[1]]) > 3
```

```{r note_dev, results = 'asis', echo = FALSE}
if (devel) {
cat(
"**Note**: ",
"This documentation refers to the development version of `scoringutils`. ",
"You can also view the [documentation of the stable version]",
"(https://epiforecasts.io/scoringutils).",
sep = ""
)
} else {
cat(
"**Note**: ",
"This documentation refers to the stable version of `scoringutils`. ",
"You can also view the [documentation of the development version]",
"(https://epiforecasts.io/scoringutils/dev).",
sep = ""
)
}
cat("\n\n")
```

The `scoringutils` package provides a collection of metrics and proper scoring rules and aims to make it simple to score probabilistic forecasts against observed values.
Expand Down
39 changes: 0 additions & 39 deletions man/abs_error.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion man/ae_median_quantile.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/ae_median_sample.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions man/se_mean_sample.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 0 additions & 31 deletions man/squared_error.Rd

This file was deleted.

17 changes: 17 additions & 0 deletions tests/testthat/test-metrics-quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,17 @@ test_that("interval_coverage rejects wrong inputs", {
)
})

test_that("interval_coverage_quantile throws a warning when a required quantile is not available", {
dropped_quantile_pred <- predicted[, -4]
dropped_quantiles <- quantile[-4]
expect_warning(
interval_coverage_quantile(
observed, dropped_quantile_pred, dropped_quantiles, range = 50
),
"To compute the interval coverage for a range of 50%, the quantiles `0.25, 0.75` are required. Returning `NA`"
)
})


# ============================================================================ #
# `interval_coverage_deviation` ===================================== #
Expand All @@ -617,6 +628,12 @@ test_that("interval_coverage_deviation works", {
interval_coverage_deviation(observed, predicted, quantile),
manual
)
expect_warning(
interval_coverage_dev_quantile(
observed, predicted, c(quantile[-4], 0.76)
),
"To compute inteval coverage deviation, all quantiles must form central symmetric prediction intervals. Missing quantiles: 0.24, 0.75. Returning `NA`."
)
})


Expand Down

0 comments on commit 3c57faf

Please sign in to comment.