Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a3b0753
Update input check functions to adhere to checkmate structure with ch…
nikosbosse Oct 23, 2023
aeb725c
Add functions to test the forecast type of the data used as input for…
nikosbosse Oct 23, 2023
b299331
move global variables to its own file
nikosbosse Oct 25, 2023
e3f6b54
Create a function, `validate()`, that replaces `check_forecasts()` an…
nikosbosse Oct 25, 2023
e30da91
Remove excessive checks from get_forecast_type, create new function c…
nikosbosse Oct 25, 2023
d847ae8
fix input checks for scoring functions
nikosbosse Oct 25, 2023
0a96dd1
remove check_forecasts.R, move input check helpers to new file, creat…
nikosbosse Oct 25, 2023
346eb54
Use validate() everywhere instead of check_forecasts
nikosbosse Oct 25, 2023
d67446a
update utils file with get_prediction_type and get_forecast_unit
nikosbosse Oct 25, 2023
8d0bf69
update documentation
nikosbosse Oct 25, 2023
2812b21
Update tests
nikosbosse Oct 25, 2023
603d042
update snapshots - apparently the order of models has changed for som…
nikosbosse Oct 25, 2023
353f07f
Automatic readme update
actions-user Oct 25, 2023
2f0990b
Reorganise files such that scores can be found in files called "metri…
nikosbosse Oct 25, 2023
8510598
update documentation for moved metrics
nikosbosse Oct 25, 2023
ee2a94c
Reorganise files for input check functions and helpers
nikosbosse Oct 25, 2023
b573e82
remove unneeded check functions
nikosbosse Oct 25, 2023
aa112aa
Renamed `find_duplicates()` to `get_duplicate_forecasts()`, reorganis…
nikosbosse Oct 25, 2023
e0648a1
Update news.md
nikosbosse Oct 25, 2023
1207d2a
Add tests for get_duplicate_forecasts, update documentation
nikosbosse Oct 25, 2023
9c8447c
Create / update example data for point forecasts
nikosbosse Oct 25, 2023
7b19334
fix point forecast example data
nikosbosse Oct 25, 2023
8ffed2e
change error to a message in `mad_sample()` if `observed` is provided
nikosbosse Oct 26, 2023
679bed9
Rewrite `score()` as S3 method. score.scoringutils_quantile() still m…
nikosbosse Oct 26, 2023
0a93c6e
update tests for score(), delete old files
nikosbosse Oct 26, 2023
3ad29c1
Remove message in mad_sample()
nikosbosse Oct 26, 2023
83b7589
Replace metrics argument in score by a list of functions
nikosbosse Oct 26, 2023
3b4b742
Create documentation for metrics_ data
nikosbosse Oct 26, 2023
a202e0c
Handle `...` function arguments that get passed through `score()` mor…
nikosbosse Oct 26, 2023
c005b14
Create first version of a function to validate metric inputs
nikosbosse Oct 26, 2023
e31d100
Add tests for the validate_metrics function
nikosbosse Oct 26, 2023
caf3ecc
Address issues raised by Sam: rename geom_mean() --> geometric_mean()…
nikosbosse Oct 26, 2023
36025b3
Merge branch 'rework-lower-level-fcts' into rework-score()
nikosbosse Oct 26, 2023
52640c9
Remove "clever" code to fix unnamed metrics argument and restrict it …
nikosbosse Oct 26, 2023
42d55fe
update tests to reflect change that metrics need to be a named list now
nikosbosse Oct 26, 2023
4689e68
Update some more documentation
nikosbosse Oct 26, 2023
09b941e
Merge branch 'scoringutils-review' into rework-score()
nikosbosse Nov 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Imports:
ggplot2 (>= 3.4.0),
lifecycle,
methods,
Metrics,
rlang,
scoringRules,
stats
Expand Down
28 changes: 25 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

S3method(plot,scoringutils_available_forecasts)
S3method(print,scoringutils_check)
S3method(score,default)
S3method(score,scoringutils_binary)
S3method(score,scoringutils_point)
S3method(score,scoringutils_quantile)
S3method(score,scoringutils_sample)
S3method(validate,default)
S3method(validate,scoringutils_binary)
S3method(validate,scoringutils_point)
S3method(validate,scoringutils_quantile)
S3method(validate,scoringutils_sample)
export(abs_error)
export(add_coverage)
export(ae_median_quantile)
Expand All @@ -13,11 +23,10 @@ export(bias_quantile)
export(bias_range)
export(bias_sample)
export(brier_score)
export(check_forecasts)
export(correlation)
export(crps_sample)
export(dss_sample)
export(find_duplicates)
export(get_duplicate_forecasts)
export(interval_score)
export(log_shift)
export(logs_binary)
Expand All @@ -26,6 +35,7 @@ export(mad_sample)
export(make_NA)
export(make_na)
export(merge_pred_and_obs)
export(new_scoringutils)
export(pairwise_comparison)
export(pit)
export(pit_sample)
Expand All @@ -50,13 +60,25 @@ export(summarise_scores)
export(summarize_scores)
export(theme_scoringutils)
export(transform_forecasts)
export(validate)
export(validate_general)
importFrom(Metrics,ae)
importFrom(Metrics,ape)
importFrom(Metrics,se)
importFrom(checkmate,assert)
importFrom(checkmate,assert_data_frame)
importFrom(checkmate,assert_data_table)
importFrom(checkmate,assert_factor)
importFrom(checkmate,assert_list)
importFrom(checkmate,assert_numeric)
importFrom(checkmate,check_atomic_vector)
importFrom(checkmate,check_data_frame)
importFrom(checkmate,check_function)
importFrom(checkmate,check_matrix)
importFrom(checkmate,check_numeric)
importFrom(checkmate,test_factor)
importFrom(checkmate,test_list)
importFrom(checkmate,test_numeric)
importFrom(data.table,"%like%")
importFrom(data.table,':=')
importFrom(data.table,.I)
Expand All @@ -71,6 +93,7 @@ importFrom(data.table,melt)
importFrom(data.table,nafill)
importFrom(data.table,rbindlist)
importFrom(data.table,setDT)
importFrom(data.table,setattr)
importFrom(data.table,setnames)
importFrom(ggdist,geom_lineribbon)
importFrom(ggplot2,.data)
Expand Down Expand Up @@ -113,7 +136,6 @@ importFrom(ggplot2,xlab)
importFrom(ggplot2,ylab)
importFrom(lifecycle,deprecated)
importFrom(methods,hasArg)
importFrom(methods,is)
importFrom(rlang,enexprs)
importFrom(rlang,warn)
importFrom(scoringRules,crps_sample)
Expand Down
37 changes: 20 additions & 17 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
# scoringutils 1.3

This major update introduces a lot of breaking changes and addresses comments made by review from the Journal of Statistical Software (see preprint of the manuscript [here](https://arxiv.org/abs/2205.07090)).
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)).

The update introduces breaking changes. If you want to keep using the older version, you can download it using `remotes::install_github("epiforecasts/scoringutils@v1.2")`.

## Package updates
- in `score()`, required columns "true_value" and "prediction" were replaced by required columns "observed" and "predicted". Scoring functions now also use the function arguements "observed" and "predicted" everywhere consistently.
- scoring functions received a consistent interface and input checks:
- metrics for binary forecasts:
- In `score()`, required columns "true_value" and "prediction" were renamed and replaced by required columns "observed" and "predicted". Scoring functions now also use the function arguments "observed" and "predicted" everywhere consistently.
- Scoring functions received a consistent interface and input checks:
- metrics for binary forecasts:
- `observed`: factor with exactly 2 levels
- `predicted`: numeric, vector with probabilities
- metrics for point forecasts:
- metrics for point forecasts:
- `observed`: numeric vector
- `predicted`: numeric vector
- metrics for sample-based forecasts:
- metrics for sample-based forecasts:
- `observed`: numeric, either a scalar or a vector
- `predicted`: numeric, a vector (if `observed` is a scalar) or a matrix (if `observed` is a vector)
- metrics for quantile-based forecasts:
- metrics for quantile-based forecasts:
- `observed`: numeric, either a scalar or a vector
- `predicted`: numeric, a vector (if `observed` is a scalar) or a matrix (if `observed` is a vector)
- `quantile`: numeric, a vector with quantile-levels. Can alternatively be a matrix of the same shape as `predicted`.
- changes to `avail_forecasts()` and `plot_avail_forecasts()`:
- the function `avail_forecasts()` was renamed to `available_forecasts()` for consistency with `available_metrics()`. The old function, `avail_forecasts()` is still available as an alias, but will be removed in the future.
- For clarity, the output column in `avail_forecasts()` was renamed from "Number forecasts" to "count".
- `available_forecasts()` now also displays combinations where there are 0 forecasts, instead of silently dropping corresponding rows.
- `plot_avail_forecasts()` has been deprecated in favour of an S3 method for `plot()`. An alias is still available, but will be removed in the future.
- remove hard-coded rounding value for `correlation()`. Previously, the function always rounded correlations to two digits. Instead, a new argument, `digits` was introduced and the default set to 0, meaning that no rounding takes place.
- 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()`.
- add documentation for the return value of `summarise_scores()`.
- `quantile`: numeric, a vector with quantile-levels. Can alternatively be a matrix of the same shape as `predicted`.
- `check_forecasts()` was replaced by a new function `validate()`. `validate()` validates the input and in that sense fulfills the purpose of `check_forecasts()`. It has different methods: `validate.default()` assigns the input a class based on their forecast type. Other methods validate the input specifically for the various forecast types.
- The function `find_duplicates()` was renamed to `get_duplicate_forecasts()`
- Changes to `avail_forecasts()` and `plot_avail_forecasts()`:
- The function `avail_forecasts()` was renamed to `available_forecasts()` for consistency with `available_metrics()`. The old function, `avail_forecasts()` is still available as an alias, but will be removed in the future.
- For clarity, the output column in `avail_forecasts()` was renamed from "Number forecasts" to "count".
- `available_forecasts()` now also displays combinations where there are 0 forecasts, instead of silently dropping corresponding rows.
- `plot_avail_forecasts()` has been deprecated in favour of an S3 method for `plot()`. An alias is still available, but will be removed in the future.
- 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()`.
- added documentation for the return value of `summarise_scores()`.

# scoringutils 1.2.1

Expand Down
8 changes: 3 additions & 5 deletions R/available_forecasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ available_forecasts <- function(data,
by = NULL,
collapse = c("quantile", "sample")) {

check_data <- check_forecasts(data)

data <- check_data$cleaned_data
forecast_unit <- check_data$forecast_unit
data <- validate(data)
forecast_unit <- attr(data, "forecast_unit")
data <- remove_na_observed_predicted(data)

if (is.null(by)) {
by <- forecast_unit
Expand Down Expand Up @@ -90,4 +89,3 @@ avail_forecasts <- function(data,
)
available_forecasts(data, by, collapse)
}

Loading