Skip to content

Commit

Permalink
Merge branch 'main' into fix-lint-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lshandross authored Apr 4, 2024
2 parents f90e0cc + f878abc commit 22f1373
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
6 changes: 5 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ Authors@R: c(
comment = c(ORCID = "0000-0002-0639-3728")),
person("Anna", "Krystalli", , "annakrystalli@googlemail.com",
role = c("ctb"),
comment = c(ORCID = "0000-0002-2378-4915")))
comment = c(ORCID = "0000-0002-2378-4915")),
person("Nicholas G.", "Reich", email = "nick@umass.edu",
role = c("ctb"),
comment = c(ORCID = "0000-0003-3503-9899")))
Description: Functions for combining model outputs (e.g. predictions or
estimates) from multiple models into an aggregated ensemble model output.
License: MIT + file LICENSE
Expand Down Expand Up @@ -46,6 +49,7 @@ Imports:
magrittr,
matrixStats,
purrr,
rlang,
tidyr,
tidyselect
Remotes:
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export("%>%")
export(linear_pool)
export(simple_ensemble)
importFrom(magrittr,"%>%")
importFrom(rlang,.data)
Empty file added R/hubEnsembles-package.R
Empty file.
4 changes: 3 additions & 1 deletion R/linear_pool.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
#' all.equal(lp_from_component_qs$value, lp_qs, tolerance = 1e-3,
#' check.attributes=FALSE)
#'
#' @importFrom rlang .data

linear_pool <- function(model_outputs, weights = NULL,
weights_col_name = "weight",
model_id = "hub-ensemble",
Expand All @@ -100,7 +102,7 @@ linear_pool <- function(model_outputs, weights = NULL,

# calculate linear opinion pool for different types
ensemble_model_outputs <- model_outputs_validated |>
dplyr::group_split(output_type) |>
dplyr::group_split(.data$output_type) |>
purrr::map_dfr(.f = function(split_outputs) {
type <- split_outputs$output_type[1]
if (type %in% c("mean", "cdf", "pmf")) {
Expand Down
1 change: 1 addition & 0 deletions R/linear_pool_quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#' 3. Collect the samples from all component models and extract the desired quantiles.
#' Steps 1 and 2 in this process are performed by `distfromq::make_q_fun`.
#' @return a `model_out_tbl` object of ensemble predictions for the `quantile` output type.
#' @importFrom rlang .data

linear_pool_quantile <- function(model_outputs, weights = NULL,
weights_col_name = "weight",
Expand Down
10 changes: 5 additions & 5 deletions R/validate_output_type_ids.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
#' @return no return value
#'
#' @noRd
#'
#' @importFrom rlang .data

validate_output_type_ids <- function(model_outputs, task_id_cols) {
same_output_id <- model_outputs |>
dplyr::filter(output_type %in% c("cdf", "pmf", "quantile")) |>
dplyr::group_by(model_id, dplyr::across(dplyr::all_of(task_id_cols)), output_type) |>
dplyr::summarize(output_type_id_list=list(sort(output_type_id))) |>
dplyr::filter(.data$output_type %in% c("cdf", "pmf", "quantile")) |>
dplyr::group_by(.data$model_id, dplyr::across(dplyr::all_of(task_id_cols)), .data$output_type) |>
dplyr::summarize(output_type_id_list=list(sort(.data$output_type_id))) |>
dplyr::ungroup() |>
dplyr::group_split(dplyr::across(dplyr::all_of(task_id_cols)), output_type) |>
dplyr::group_split(dplyr::across(dplyr::all_of(task_id_cols)), .data$output_type) |>
purrr::map(.f = function(split_outputs) {
length(unique(split_outputs$output_type_id_list)) == 1
}) |>
Expand Down

0 comments on commit 22f1373

Please sign in to comment.