Skip to content

Hardhat quantiles #400

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

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
dd9c92e
fix and add test
dajmcdon Sep 11, 2024
9b47549
bump version, news
dajmcdon Sep 11, 2024
fbceb88
try to retain the class to the extent possible
dajmcdon Sep 12, 2024
9cf5b85
bump version
dajmcdon Sep 12, 2024
4d8a24d
import rlang checks since checkmate doesn't take an environment
dajmcdon Sep 13, 2024
73579e5
current tests pass
dajmcdon Sep 19, 2024
79c56fc
replace expect_error with expect_snapshot to log the message as well
dajmcdon Sep 19, 2024
0d1064a
adjust imports and document
dajmcdon Sep 19, 2024
96d5b9f
create snapshot tests
dajmcdon Sep 19, 2024
1822985
news, bump version, run styler
dajmcdon Sep 19, 2024
f7fec68
make internal versioning accurate
dsweber2 Sep 25, 2024
070cb1d
Merge pull request #385 from cmu-delphi/epiprocessUpperBound
dshemetov Sep 26, 2024
acaca4f
add missing topic
dajmcdon Sep 27, 2024
cd12775
Merge pull request #388 from cmu-delphi/fix-failing-pkgdown
dajmcdon Sep 27, 2024
0e7d90f
fix: update for compatibility with epiprocess==0.9.0
dshemetov Sep 26, 2024
b3e3189
styler: style
dshemetov Sep 27, 2024
374cb2f
doc: fix vignettes
dshemetov Sep 27, 2024
34cb6ed
Merge pull request #386 from cmu-delphi/ds/epiprocess-0.9.0
dshemetov Sep 27, 2024
93a405e
doc: fix sliding article and verify others
dshemetov Sep 28, 2024
525618a
Merge pull request #392 from cmu-delphi/ds/fix-articles
dshemetov Sep 28, 2024
9c35fb9
Merge branch 'dev' into retain-epi_df-class
dajmcdon Sep 30, 2024
1caa549
error if not an epidf in epirecipe
dajmcdon Sep 30, 2024
37d2352
test: snapshot step_* errors
dshemetov Sep 30, 2024
7222b36
Merge branch 'dev' into 287-surface-step-name
dshemetov Sep 30, 2024
78fbaa0
repo: bump version
dshemetov Sep 30, 2024
bffc03b
redocument
dajmcdon Sep 30, 2024
65385e2
test: add new snapshots
dshemetov Sep 30, 2024
db2cfee
Merge pull request #379 from cmu-delphi/retain-epi_df-class
dshemetov Sep 30, 2024
addb2ae
repo: bump version
dshemetov Sep 30, 2024
de0add1
Merge branch 'dev' into 363-no-drop-epiwf-class
dshemetov Sep 30, 2024
1c01028
Merge pull request #377 from cmu-delphi/363-no-drop-epiwf-class
dshemetov Sep 30, 2024
1ff2efc
Merge branch 'dev' into 287-surface-step-name
dshemetov Sep 30, 2024
434262a
repo: bump version
dshemetov Sep 30, 2024
37f3ad0
Merge pull request #383 from cmu-delphi/287-surface-step-name
dajmcdon Sep 30, 2024
cebc672
repo: fix imports and remove unused standalone files
dshemetov Sep 30, 2024
f588f0a
tests: snapshot tests on errors
dshemetov Sep 30, 2024
0bb8a35
Merge pull request #395 from cmu-delphi/ds/dependencies
dajmcdon Sep 30, 2024
36c4c0a
Merge pull request #393 from cmu-delphi/ds/snapshots
dajmcdon Sep 30, 2024
b74c039
skeleton
dajmcdon Sep 30, 2024
aa41827
bump version, promote authors, add funder
dajmcdon Sep 30, 2024
7ee015a
add math ops, test
dajmcdon Oct 1, 2024
44da76d
pass tests
dajmcdon Oct 1, 2024
56d927a
Merge pull request #391 from cmu-delphi/dev
dshemetov Oct 1, 2024
faa9440
woodshedding wis
dajmcdon Oct 1, 2024
2646b0e
pass local tests
dajmcdon Oct 1, 2024
b4fa6e6
strange unpassable snapshot test
dajmcdon Oct 1, 2024
be4fd5d
remove old snap
dajmcdon Oct 1, 2024
0167700
excise dist_quantiles and nested_quantiles
dajmcdon Oct 1, 2024
dd5f555
merge main due to epiprocess dependencies
dajmcdon Oct 1, 2024
87e5163
all tests pass
dajmcdon Oct 2, 2024
3d58952
tests/checks pass. done.
dajmcdon Oct 2, 2024
ed88db6
needs dev hardhat
dajmcdon Oct 21, 2024
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
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
^DEVELOPMENT\.md$
^doc$
^Meta$
^.lintr$
^.lintr$
^.venv$
17 changes: 10 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ Package: epipredict
Title: Basic epidemiology forecasting methods
Version: 0.1.0
Authors@R: c(
person("Daniel", "McDonald", , "daniel@stat.ubc.ca", role = c("aut", "cre")),
person("Daniel J.", "McDonald", , "daniel@stat.ubc.ca", role = c("aut", "cre")),
person("Ryan", "Tibshirani", , "ryantibs@cmu.edu", role = "aut"),
person("Dmitry", "Shemetov", email = "dshemeto@andrew.cmu.edu", role = "aut"),
person("David", "Weber", email = "davidweb@andrew.cmu.edu", role = "aut"),
person("CMU's Delphi Research Group", role = c("cph", "fnd")),
person("Logan", "Brooks", role = "aut"),
person("Rachel", "Lobay", role = "aut"),
person("Dmitry", "Shemetov", email = "dshemeto@andrew.cmu.edu", role = "ctb"),
person("David", "Weber", email = "davidweb@andrew.cmu.edu", role = "ctb"),
person("Maggie", "Liu", role = "ctb"),
person("Ken", "Mawer", role = "ctb"),
person("Chloe", "You", role = "ctb"),
Expand All @@ -23,7 +24,7 @@ URL: https://github.com/cmu-delphi/epipredict/,
https://cmu-delphi.github.io/epipredict
BugReports: https://github.com/cmu-delphi/epipredict/issues/
Depends:
epiprocess (>= 0.7.12),
epiprocess (>= 0.9.0),
parsnip (>= 1.0.0),
R (>= 3.5.0)
Imports:
Expand All @@ -34,10 +35,11 @@ Imports:
generics,
ggplot2,
glue,
hardhat (>= 1.3.0),
hardhat (>= 1.4.0.9002),
lifecycle,
magrittr,
recipes (>= 1.0.4),
rlang (>= 1.0.0),
rlang (>= 1.1.0),
stats,
tibble,
tidyr,
Expand Down Expand Up @@ -68,7 +70,8 @@ VignetteBuilder:
Remotes:
cmu-delphi/epidatr,
cmu-delphi/epiprocess,
dajmcdon/smoothqr
dajmcdon/smoothqr,
tidymodels/hardhat
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Expand Down
67 changes: 23 additions & 44 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

S3method(Add_model,epi_workflow)
S3method(Add_model,workflow)
S3method(Math,dist_quantiles)
S3method(Ops,dist_quantiles)
S3method(Remove_model,epi_workflow)
S3method(Remove_model,workflow)
S3method(Update_model,epi_workflow)
Expand Down Expand Up @@ -38,20 +36,14 @@ S3method(extract_frosting,default)
S3method(extract_frosting,epi_workflow)
S3method(extract_layers,frosting)
S3method(extract_layers,workflow)
S3method(extrapolate_quantiles,dist_default)
S3method(extrapolate_quantiles,dist_quantiles)
S3method(extrapolate_quantiles,distribution)
S3method(extrapolate_quantiles,quantile_pred)
S3method(fit,epi_workflow)
S3method(flusight_hub_formatter,canned_epipred)
S3method(flusight_hub_formatter,data.frame)
S3method(forecast,epi_workflow)
S3method(format,dist_quantiles)
S3method(is.na,dist_quantiles)
S3method(is.na,distribution)
S3method(key_colnames,epi_workflow)
S3method(key_colnames,recipe)
S3method(mean,dist_quantiles)
S3method(median,dist_quantiles)
S3method(mean,quantile_pred)
S3method(predict,epi_workflow)
S3method(predict,flatline)
S3method(prep,check_enough_train_data)
Expand Down Expand Up @@ -93,7 +85,7 @@ S3method(print,step_lag_difference)
S3method(print,step_naomit)
S3method(print,step_population_scaling)
S3method(print,step_training_window)
S3method(quantile,dist_quantiles)
S3method(quantile,quantile_pred)
S3method(recipe,epi_df)
S3method(recipes::recipe,formula)
S3method(refresh_blueprint,default_epi_recipe_blueprint)
Expand All @@ -112,19 +104,17 @@ S3method(slather,layer_residual_quantiles)
S3method(slather,layer_threshold)
S3method(slather,layer_unnest)
S3method(snap,default)
S3method(snap,dist_default)
S3method(snap,dist_quantiles)
S3method(snap,distribution)
S3method(snap,quantile_pred)
S3method(tidy,check_enough_train_data)
S3method(tidy,frosting)
S3method(tidy,layer)
S3method(update,layer)
S3method(vec_ptype_abbr,dist_quantiles)
S3method(vec_ptype_full,dist_quantiles)
S3method(vec_arith,quantile_pred)
S3method(vec_arith.numeric,quantile_pred)
S3method(vec_arith.quantile_pred,numeric)
S3method(vec_math,quantile_pred)
S3method(weighted_interval_score,default)
S3method(weighted_interval_score,dist_default)
S3method(weighted_interval_score,dist_quantiles)
S3method(weighted_interval_score,distribution)
S3method(weighted_interval_score,quantile_pred)
export("%>%")
export(Add_model)
export(Remove_model)
Expand All @@ -142,6 +132,7 @@ export(arx_class_epi_workflow)
export(arx_classifier)
export(arx_fcast_epi_workflow)
export(arx_forecaster)
export(as_tibble)
export(autoplot)
export(bake)
export(cdc_baseline_args_list)
Expand All @@ -150,7 +141,6 @@ export(check_enough_train_data)
export(clean_f_name)
export(default_epi_recipe_blueprint)
export(detect_layer)
export(dist_quantiles)
export(epi_recipe)
export(epi_workflow)
export(extract_argument)
Expand Down Expand Up @@ -181,10 +171,10 @@ export(layer_quantile_distn)
export(layer_residual_quantiles)
export(layer_threshold)
export(layer_unnest)
export(nested_quantiles)
export(pivot_quantiles_longer)
export(pivot_quantiles_wider)
export(prep)
export(quantile_pred)
export(quantile_reg)
export(rand_id)
export(recipe)
Expand All @@ -208,22 +198,18 @@ export(update_frosting)
export(update_model)
export(validate_layer)
export(weighted_interval_score)
import(distributional)
import(epiprocess)
import(parsnip)
import(recipes)
importFrom(checkmate,assert)
importFrom(checkmate,assert_character)
importFrom(checkmate,assert_class)
importFrom(checkmate,assert_date)
importFrom(checkmate,assert_function)
importFrom(checkmate,assert_int)
importFrom(checkmate,assert_integer)
importFrom(checkmate,assert_integerish)
importFrom(checkmate,assert_logical)
importFrom(checkmate,assert_number)
importFrom(checkmate,assert_numeric)
importFrom(checkmate,assert_scalar)
importFrom(checkmate,test_character)
importFrom(checkmate,test_date)
importFrom(checkmate,test_function)
importFrom(checkmate,test_integerish)
importFrom(checkmate,test_logical)
importFrom(checkmate,test_numeric)
importFrom(checkmate,test_scalar)
importFrom(cli,cli_abort)
importFrom(cli,cli_warn)
importFrom(dplyr,across)
Expand Down Expand Up @@ -256,6 +242,7 @@ importFrom(ggplot2,geom_line)
importFrom(ggplot2,geom_linerange)
importFrom(ggplot2,geom_point)
importFrom(ggplot2,geom_ribbon)
importFrom(hardhat,quantile_pred)
importFrom(hardhat,refresh_blueprint)
importFrom(hardhat,run_mold)
importFrom(magrittr,"%>%")
Expand All @@ -271,6 +258,7 @@ importFrom(rlang,":=")
importFrom(rlang,abort)
importFrom(rlang,arg_match)
importFrom(rlang,as_function)
importFrom(rlang,caller_arg)
importFrom(rlang,caller_env)
importFrom(rlang,enquo)
importFrom(rlang,enquos)
Expand All @@ -283,24 +271,15 @@ importFrom(rlang,is_true)
importFrom(rlang,set_names)
importFrom(rlang,sym)
importFrom(stats,as.formula)
importFrom(stats,family)
importFrom(stats,lm)
importFrom(stats,median)
importFrom(stats,model.frame)
importFrom(stats,poly)
importFrom(stats,predict)
importFrom(stats,qnorm)
importFrom(stats,quantile)
importFrom(stats,residuals)
importFrom(tibble,as_tibble)
importFrom(tibble,tibble)
importFrom(tidyr,crossing)
importFrom(vctrs,as_list_of)
importFrom(vctrs,field)
importFrom(vctrs,new_rcrd)
importFrom(vctrs,new_vctr)
importFrom(vctrs,vec_cast)
importFrom(vctrs,vec_data)
importFrom(vctrs,vec_ptype_abbr)
importFrom(vctrs,vec_ptype_full)
importFrom(vctrs,vec_recycle_common)
importFrom(vctrs,vec_arith)
importFrom(vctrs,vec_arith.numeric)
importFrom(vctrs,vec_math)
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.0.x will indicat
- Add `step_epi_slide` to produce generic sliding computations over an `epi_df`
- Add quantile random forests (via `{grf}`) as a parsnip engine
- Replace `epi_keys()` with `epiprocess::key_colnames()`, #352
- More descriptive error messages from `arg_is_*()`, #287
- Fix bug where `fit()` drops the `epi_workflow` class (also error if
non-`epi_df` data is given to `epi_recipe()`), #363
- Try to retain the `epi_df` class during baking to the extent possible, #376
4 changes: 2 additions & 2 deletions R/autoplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ autoplot.epi_workflow <- function(
if (length(extra_keys) == 0L) extra_keys <- NULL
edf <- as_epi_df(edf,
as_of = object$fit$meta$as_of,
additional_metadata = list(other_keys = extra_keys)
other_keys = extra_keys %||% character()
)
if (is.null(predictions)) {
return(autoplot(
Expand Down Expand Up @@ -248,7 +248,7 @@ plot_bands <- function(
ntarget_dates <- dplyr::n_distinct(predictions$time_value)

predictions <- predictions %>%
mutate(.pred_distn = dist_quantiles(quantile(.pred_distn, l), l)) %>%
mutate(.pred_distn = quantile_pred(quantile(.pred_distn, l), l)) %>%
pivot_quantiles_wider(.pred_distn)
qnames <- setdiff(names(predictions), innames)

Expand Down
4 changes: 2 additions & 2 deletions R/cdc_baseline_forecaster.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#' mutate(deaths = pmax(death_rate / 1e5 * pop * 7, 0)) %>%
#' select(-pop, -death_rate) %>%
#' group_by(geo_value) %>%
#' epi_slide(~ sum(.$deaths), before = 6, new_col_name = "deaths") %>%
#' epi_slide(~ sum(.$deaths), .window_size = 7, .new_col_name = "deaths_7dsum") %>%
#' ungroup() %>%
#' filter(weekdays(time_value) == "Saturday")
#'
#' cdc <- cdc_baseline_forecaster(weekly_deaths, "deaths")
#' cdc <- cdc_baseline_forecaster(weekly_deaths, "deaths_7dsum")
#' preds <- pivot_quantiles_wider(cdc$predictions, .pred_distn)
#'
#' library(ggplot2)
Expand Down
Loading
Loading