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

Fix population scaling with other_keys + supporting fixes/changes #422

Merged
merged 11 commits into from
Nov 11, 2024

Conversation

brookslogan
Copy link
Contributor

@brookslogan brookslogan commented Oct 29, 2024

Checklist

Please:

  • Make sure this PR is against "dev", not "main".
  • Request a review from one of the current epipredict main reviewers:
    dajmcdon.
  • Make sure to bump the version number in DESCRIPTION and NEWS.md.
    Always increment the patch version number (the third number), unless you are
    making a release PR from dev to main, in which case increment the minor
    version number (the second number).
  • Describe changes made in NEWS.md, making sure breaking changes
    (backwards-incompatible changes to the documented interface) are noted.
    Collect the changes under the next release number (e.g. if you are on
    0.7.2, then write your changes under the 0.8 heading).
  • Consider pinning the epiprocess version in the DESCRIPTION file if
    • You anticipate breaking changes in epiprocess soon
    • You want to co-develop features in epipredict and epiprocess

Change explanations for reviewer

  • Replaces ignored argument extra_keys = with other_keys =, which is sometimes used in current epiprocess, and will consistently be used/checked in pending epiprocess versions.
  • Fixes layer_population_scaling(by = NULL) when there are other_keys.
  • Moves step_population_scaling default by setting to prep; try to improve messaging.
  • Change grab_forged_keys and key_colnames to try to be more self-consistent and consistent with pending epiprocess key_colnames updates.
    • If any of the "geo_value", "key", or "time_value" roles are present, use them to decide on key.
      • This should include if we are given an epi_df as training/test data, as this should set roles.
    • Else use intersection of c("geo_value", "time_value") and available columns. (Though population scaling attempts to deviate from this, instead using the intersection of all column names in the training/test data with non-population column names in the population data. It works for the step, but since postprocessing seems to require an epi_df, it doesn't effectively work on the layer.)
  • Make step_population_scaling work with non-epi_dfs.
  • Make layer_population_scaling work with non-epi_dfs it has both the "geo_value" and "time_value" columns, and, if other key columns are present, that all the epikeytime roles are manually set.
  • Fix quantile_reg errors producing just single predictions, to enable writing "simple" tests.

Magic GitHub syntax to mark associated Issue(s) as resolved when this is merged into the default branch

Recent/current epiprocess versions silently ignore `extra_keys =`. Pending
epiprocess changes will soft-deprecate and route it to `other_keys =` instead,
plus add some stricter checks on `other_keys =`.
- Rename `extra_keys` -> `other_keys` when we are going to feed it into
  `other_keys =`.
- Remove some `<edf metadata>$other_keys %||% character()` hedges now that
  current epiprocess standardizes to character() not NULL and example `epi_df`
  objects have been updated to that standard.
- Roles should already factor in key_colnames.
@brookslogan brookslogan marked this pull request as ready for review October 29, 2024 23:23
@brookslogan brookslogan requested a review from dajmcdon as a code owner October 29, 2024 23:23
@@ -112,7 +112,7 @@ make_quantile_reg <- function() {

# can't make a method because object is second
out <- switch(type,
rq = dist_quantiles(unname(as.list(x)), object$quantile_levels), # one quantile
rq = dist_quantiles(unname(as.list(x)), object$tau), # one quantile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this didn't raise an error before...

@dajmcdon dajmcdon merged commit ea34700 into cmu-delphi:dev Nov 11, 2024
2 checks passed
@brookslogan brookslogan deleted the lcb/key_colnames-downstream branch November 12, 2024 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants