Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update branch from master #146

Merged
merged 20 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
21 changes: 10 additions & 11 deletions .github/workflows/check-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ on:
push:
branches:
- master
schedule:
- cron: "0 0 * * *"
pull_request:
branches:
- master
Expand All @@ -20,12 +18,10 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'devel'}
- {os: macOS-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}

- {os: ubuntu-20.04, r: 'release'}
- {os: ubuntu-20.04, r: 'oldrel'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
Expand Down Expand Up @@ -60,15 +56,18 @@ jobs:
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
sudo apt-get -y install libudunits2-dev libgdal-dev libqpdf-dev libcurl4-openssl-dev
shell: bash

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export(score_heatmap)
export(score_table)
export(sharpness)
export(show_avail_forecasts)
export(update_list)
export(wis_components)
importFrom(data.table,"%like%")
importFrom(data.table,':=')
Expand Down
48 changes: 25 additions & 23 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
## scoringutils 0.1.7.2
# scoringutils 0.1.7.2

### Package updates
## Package updates
- minor bug fixes (previously, 'interval_score' needed to be among the
selected metrics)
- all data.tables are now returned as `table[]` rather than as `table`,
such that they don't have to be called twice to display the contents.

## scoringutils 0.1.7
# scoringutils 0.1.7

### Feature updates
## Feature updates
- added a function, `pairwise_comparison()` that runs pairwise comparisons
between models on the output of `eval_forecasts()`
- added functionality to compute relative skill within `eval_forecasts()`
- added a function to visualise pairwise comparisons

### Package updates
## Package updates
- The WIS definition change introduced in version 0.1.5 was partly corrected
such that the difference in weighting is only introduced when summarising
over scores from different interval ranges

## scoringutils 0.1.
# scoringutils 0.1.

### Feature updates
## Feature updates
- `eval_forecasts()` can now handle a separate forecast and truth data set as
as input
- `eval_forecasts()` now supports scoring point forecasts along side quantiles
in a quantile-based format. Currently the only metric used is the absolute error

### Package updates
## Package updates
- Many functions, especially `eval_forecasts()` got a major rewrite. While
functionality should be unchanged, the code should now be easier to maintain
- Some of the data-handling functions got renamed, but old names are supported
as well for now.


## scoringutils 0.1.5
# scoringutils 0.1.5

### Package updates
## Package updates
- changed the default definition of the weighted interval score. Previously,
the median prediction was counted twice, but is no only counted once. If you
want to go back to the old behaviour, you can call the interval_score function
with the argument `count_median_twice = FALSE`.

## scoringutils 0.1.4
# scoringutils 0.1.4

### Feature updates
## Feature updates
- we added basic plotting functionality to visualise scores. You can now
easily obtain diagnostic plots based on scores as produced by `eval_forecasts`.
- `correlation_plot` shows correlation between metrics
Expand All @@ -51,16 +53,16 @@ chosen metric
- `score_heatmap` visualises scores as heatmap
- `score_table` shows a coloured summary table of scores

### package updates
## package updates
- renamed "calibration" to "coverage"
- renamed "true_values" to "true_value" in data.frames
- renamed "predictions" to "prediction" in data.frames
- renamed "is_overprediction" to "overprediction"
- renamed "is_underprediction" to "underprediction"

## scoringutils 0.1.3
# scoringutils 0.1.3

### (Potentially) Breaking changes
## (Potentially) Breaking changes
- the by argument in `eval_forecasts` now has a slightly changed meaning. It
now denotes the lowest possible grouping unit, i.e. the unit of one observation
and needs to be specified explicitly. The default is now `NULL`. The reason for
Expand All @@ -72,7 +74,7 @@ to be included.
- for the interval score, `weigh = TRUE` is now the default option.
- (potentially planned) rename true_values to true_value and predictions to prediction.

### Feature updates
## Feature updates
- updated quantile evaluation metrics in `eval_forecasts`. Bias as well as
calibration now take all quantiles into account
- Included option to summarise scores according to a `summarise_by` argument in
Expand All @@ -81,31 +83,31 @@ as an arbitrary set of quantiles.
- `eval_forecasts` can now return pit histograms.
- switched to ggplot2 for plotting

## scoringutils 0.1.2
# scoringutils 0.1.2

### (Potentially) Breaking changes
## (Potentially) Breaking changes
- all scores in eval_forecasts were consistently renamed to lower case.
Interval_score is now interval_score, CRPS is now crps etc.

### Feature updates
## Feature updates
- included support for grouping scores according to a vector of column names
in `eval_forecasts`
- included support for passing down arguments to lower-level functions in
`eval_forecasts`
- included support for three new metrics to score quantiles with
`eval_forecasts`: bias, sharpness and calibration

### Package updates
## Package updates
- example data now has a horizon column to illustrate the use of grouping
- documentation updated to explain the above listed changes

## scoringutils 0.1.1
# scoringutils 0.1.1

### Feature updates
## Feature updates
- included support for a long as well as wide input formats for
quantile forecasts that are scored with `eval_forecasts`

### Package updates
## Package updates
- updated documentation for the `eval_forecasts`
- added badges to the Readme

2 changes: 2 additions & 0 deletions R/eval_forecasts_binary.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ eval_forecasts_binary <- function(data,
by = summarise_by]

}

return(res[])
}


2 changes: 1 addition & 1 deletion R/eval_forecasts_continuous_integer.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,5 @@ eval_forecasts_sample <- function(data,
pit_plots = pit_histograms)
}

return(res)
return(res[])
}
4 changes: 2 additions & 2 deletions R/eval_forecasts_helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ add_quantiles <- function(dt, varnames, quantiles, by) {
na.rm = TRUE)),
by = c(by)]
}
return(dt)
return(dt[])
}


Expand All @@ -41,5 +41,5 @@ add_sd <- function(dt, varnames, by) {
for (varname in varnames) {
dt[, paste0(varname, "_sd") := sd(get(varname), na.rm = TRUE), by = by]
}
return(dt)
return(dt[])
}
2 changes: 1 addition & 1 deletion R/eval_forecasts_quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,5 @@ eval_forecasts_quantile <- function(data,
res[, c("quantile_coverage") := NULL]
}

return(res)
return(res[])
}
6 changes: 4 additions & 2 deletions R/pairwise-comparisons.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ add_rel_skill_to_eval_forecasts <- function(unsummarised_scores,
# also delete skill metric from output
out[, eval(rel_skill_metric) := NULL]

return(out)
return(out[])
}


Expand Down Expand Up @@ -278,6 +278,8 @@ pairwise_comparison_one_group <- function(scores,
by = "model"]
# merge back to retain the ratios even for comparisons with the baseline
result <- merge(result, result_without_baseline, all.x = TRUE)
# avoid mixture of NA and NaN which can cause problems downstream
result[is.na(theta), theta := NA_real_]
# remove NAs form merge in the thetas
result[, theta := unique(na.omit(theta)), by = "model"]
} else {
Expand All @@ -303,7 +305,7 @@ pairwise_comparison_one_group <- function(scores,
data.table::setnames(out, old = c("ratio", "theta", "rel_to_baseline"),
new = c("mean_scores_ratio", "relative_skill", "scaled_rel_skill"))

return(out)
return(out[])
}


Expand Down
11 changes: 6 additions & 5 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -744,13 +744,14 @@ plot_predictions <- function(data = NULL,
select_median <- (forecasts$range %in% 0 & forecasts$boundary == "lower")
median <- forecasts[select_median]

plot <- plot +
ggplot2::geom_line(data = median,
mapping = ggplot2::aes(y = prediction, colour = "median"),
lwd = 0.4)
if (nrow(median) > 0) {
plot <- plot +
ggplot2::geom_line(data = median,
mapping = ggplot2::aes(y = prediction, colour = "median"),
lwd = 0.4)
}
}


# facet if specified by the user
if (!is.null(facet_formula)) {
if (facet_wrap_or_grid == "facet_wrap") {
Expand Down
1 change: 0 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ extract_from_list <- function(list, what) {
#' @param defaults A list of default settings
#' @param optional A list of optional settings to override defaults
#' @return A list
#' @export
#'
#' @keywords internal
update_list <- function(defaults = list(), optional = list()) {
Expand Down
24 changes: 12 additions & 12 deletions R/utils_data_handling.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ range_long_to_wide <- function(data) {
out <- data.table::dcast(data, ... ~ boundary + range,
value.var = "prediction")

return(out)
return(out[])
}


Expand All @@ -45,7 +45,7 @@ range_long_to_wide <- function(data) {
quantile_to_wide <- function(data) {
warning("This function will be deprecated. Please use `range_long_to_wide()` in the future")
out <- scoringutils::range_long_to_wide(data)
return(out)
return(out[])
}


Expand Down Expand Up @@ -106,7 +106,7 @@ range_wide_to_long <- function(data) {
data[, range := as.numeric(gsub("^.*?_","", range))]
}

return(data)
return(data[])
}


Expand All @@ -120,7 +120,7 @@ range_wide_to_long <- function(data) {
quantile_to_long <- function(data) {
warning("This function will be deprecated. Please use `range_wide_to_long()` in the future")
out <- scoringutils::range_wide_to_long(data)
return(out)
return(out[])
}


Expand Down Expand Up @@ -173,7 +173,7 @@ range_long_to_quantile <- function(data,
}


return(unique(data))
return(unique(data)[])
}


Expand All @@ -188,7 +188,7 @@ range_to_quantile <- function(data,
keep_range_col = FALSE) {
warning("This function will be deprecated. Please use `range_long_to_quantile()` in the future")
out <- scoringutils::range_long_to_quantile(data, keep_range_col)
return(out)
return(out[])
}


Expand Down Expand Up @@ -246,7 +246,7 @@ quantile_to_range_long <- function(data,
data[, `:=`(boundary = as.character(boundary),
range = as.numeric(range))]

return(data)
return(data[])
}


Expand All @@ -261,7 +261,7 @@ quantile_to_range <- function(data,
keep_quantile_col = FALSE) {
warning("This function will be deprecated. Please use `quantile_to_range_long()` in the future")
out <- scoringutils::quantile_to_range_long(data, keep_quantile_col)
return(out)
return(out[])
}


Expand Down Expand Up @@ -306,7 +306,7 @@ sample_to_quantile <- function(data,
type = type, na.rm = TRUE)),
by = by]

return(data)
return(data[])
}


Expand Down Expand Up @@ -354,7 +354,7 @@ sample_to_range_long <- function(data,
data <- scoringutils::quantile_to_range_long(data,
keep_quantile_col = keep_quantile_col)

return(data)
return(data[])
}


Expand All @@ -372,7 +372,7 @@ sample_to_range <- function(data,
keep_quantile_col = TRUE) {
warning("This function will be deprecated. Please use `sample_to_range-long()` in the future")
out <- scoringutils::sample_to_range_long(data, range, type, keep_quantile_col)
return(out)
return(out[])
}


Expand Down Expand Up @@ -450,7 +450,7 @@ merge_pred_and_obs <- function(forecasts, observations,
combined[, paste0(basenames_overlap, ".y") := NULL]
}

return(combined)
return(combined[])
}


Expand Down