diff --git a/DESCRIPTION b/DESCRIPTION index 40fee818..5abc8b61 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -68,9 +68,9 @@ Suggests: VignetteBuilder: knitr Remotes: + cmu-delphi/delphidocs, cmu-delphi/epidatr, cmu-delphi/epiprocess, - cmu-delphi/delphidocs dajmcdon/smoothqr Config/testthat/edition: 3 Config/Needs/website: cmu-delphi/delphidocs diff --git a/README.md b/README.md index 9d912f7e..2cd3557c 100644 --- a/README.md +++ b/README.md @@ -38,25 +38,24 @@ You can view documentation for the `main` branch at You should be able to do a reasonably limited amount of customization on them. For the basic forecasters, we currently provide: - - Baseline flatline forecaster - - Autoregressive forecaster - - Autoregressive classifier - - CDC FluSight flatline forecaster + - Baseline flatline forecaster + - Autoregressive forecaster + - Autoregressive classifier + - CDC FluSight flatline forecaster 2. A framework for creating custom forecasters out of modular components. There are four types of components: - - Preprocessor: do things to the data before model training - - Trainer: train a model on data, resulting in a fitted model - object - - Predictor: make predictions, using a fitted model object - - Postprocessor: do things to the predictions before returning + - Preprocessor: do things to the data before model training + - Trainer: train a model on data, resulting in a fitted model object + - Predictor: make predictions, using a fitted model object + - Postprocessor: do things to the predictions before returning **Target audiences:** - - Basic. Has data, calls forecaster with default arguments. - - Intermediate. Wants to examine changes to the arguments, take - advantage of built in flexibility. - - Advanced. Wants to write their own forecasters. Maybe willing to - build up from some components. +- Basic. Has data, calls forecaster with default arguments. +- Intermediate. Wants to examine changes to the arguments, take + advantage of built in flexibility. +- Advanced. Wants to write their own forecasters. Maybe willing to build + up from some components. The Advanced user should find their task to be relatively easy. Examples of these tasks are illustrated in the [vignettes and @@ -71,7 +70,7 @@ The package comes with some built-in historical data for illustration, but up-to-date versions of this could be downloaded with the [`{epidatr}` package](https://cmu-delphi.github.io/epidatr/) and processed using -[`{epiprocess}`](https://cmu-delphi.github.io/epiprocess/).\[1\] +[`{epiprocess}`](https://cmu-delphi.github.io/epiprocess/).[^1] ``` r library(epipredict) @@ -114,7 +113,7 @@ two_week_ahead <- arx_forecaster( two_week_ahead #> ══ A basic forecaster of type ARX Forecaster ═══════════════════════════════ #> -#> This forecaster was fit on 2024-01-29 15:10:01. +#> This forecaster was fit on 2024-11-11 11:38:31. #> #> Training data was an with: #> • Geography: state, @@ -207,7 +206,7 @@ through the end of 2021 for the 14th of January 2022. A prediction for the death rate per 100K inhabitants is available for every state (`geo_value`) along with a 90% predictive interval. -1. Other epidemiological signals for non-Covid related illnesses are +[^1]: Other epidemiological signals for non-Covid related illnesses are also available with [`{epidatr}`](https://github.com/cmu-delphi/epidatr) which interfaces directly to Delphi’s [Epidata diff --git a/_pkgdown.yml b/_pkgdown.yml index 0cf3ba1f..0e589325 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -37,7 +37,7 @@ home: - text: The epiprocess package href: https://cmu-delphi.github.io/epiprocess/ sidebar: - structure: [links, license, community, citation, authors, related, dev] + structure: [links, license, community, citation, authors, dev, related] components: related: title: Delphi packages and resources diff --git a/vignettes/epipredict.Rmd b/vignettes/epipredict.Rmd index 1925de2f..0e1888dd 100644 --- a/vignettes/epipredict.Rmd +++ b/vignettes/epipredict.Rmd @@ -21,7 +21,6 @@ library(dplyr) library(parsnip) library(workflows) library(recipes) -library(epiprocess) library(epipredict) ``` @@ -226,7 +225,7 @@ symmetrized). Here, we used 23 quantiles, but one can grab a particular quantile, ```{r q1} -head(quantile(out_q$predictions$.pred_distn, p = .4)) +round(head(quantile(out_q$predictions$.pred_distn, p = .4)), 3) ``` or extract the entire distribution into a "long" `epi_df` with `quantile_levels` @@ -234,9 +233,7 @@ being the probability and `values` being the value associated to that quantile. ```{r q2} out_q$predictions %>% - # first create a "nested" list-column - mutate(.pred_distn = nested_quantiles(.pred_distn)) %>% - unnest(.pred_distn) # then unnest it + pivot_quantiles_longer(.pred_distn) ``` Additional simple adjustments to the basic forecaster can be made using the @@ -262,8 +259,10 @@ package: ```{r ranger, warning = FALSE} out_rf <- arx_forecaster( - jhu, "death_rate", c("case_rate", "death_rate"), - rand_forest(mode = "regression") + jhu, + outcome = "death_rate", + predictors = c("case_rate", "death_rate"), + trainer = rand_forest(mode = "regression") ) ``` @@ -271,8 +270,10 @@ Or boosted regression trees with `{xgboost}`: ```{r xgboost, warning = FALSE} out_gb <- arx_forecaster( - jhu, "death_rate", c("case_rate", "death_rate"), - boost_tree(mode = "regression", trees = 20) + jhu, + outcome = "death_rate", + predictors = c("case_rate", "death_rate"), + trainer = boost_tree(mode = "regression", trees = 20) ) ``` @@ -280,8 +281,10 @@ Or quantile regression, using our custom forecasting engine `quantile_reg()`: ```{r quantreg, warning = FALSE} out_qr <- arx_forecaster( - jhu, "death_rate", c("case_rate", "death_rate"), - quantile_reg() + jhu, + outcome = "death_rate", + predictors = c("case_rate", "death_rate"), + trainer = quantile_reg() ) ```