Skip to content

Commit bc155b7

Browse files
committed
rebuild README, simplify getting started
1 parent e513285 commit bc155b7

File tree

4 files changed

+32
-30
lines changed

4 files changed

+32
-30
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ Suggests:
6868
VignetteBuilder:
6969
knitr
7070
Remotes:
71+
cmu-delphi/delphidocs,
7172
cmu-delphi/epidatr,
7273
cmu-delphi/epiprocess,
73-
cmu-delphi/delphidocs
7474
dajmcdon/smoothqr
7575
Config/testthat/edition: 3
7676
Config/Needs/website: cmu-delphi/delphidocs

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,24 @@ You can view documentation for the `main` branch at
3838
You should be able to do a reasonably limited amount of
3939
customization on them. For the basic forecasters, we currently
4040
provide:
41-
- Baseline flatline forecaster
42-
- Autoregressive forecaster
43-
- Autoregressive classifier
44-
- CDC FluSight flatline forecaster
41+
- Baseline flatline forecaster
42+
- Autoregressive forecaster
43+
- Autoregressive classifier
44+
- CDC FluSight flatline forecaster
4545
2. A framework for creating custom forecasters out of modular
4646
components. There are four types of components:
47-
- Preprocessor: do things to the data before model training
48-
- Trainer: train a model on data, resulting in a fitted model
49-
object
50-
- Predictor: make predictions, using a fitted model object
51-
- Postprocessor: do things to the predictions before returning
47+
- Preprocessor: do things to the data before model training
48+
- Trainer: train a model on data, resulting in a fitted model object
49+
- Predictor: make predictions, using a fitted model object
50+
- Postprocessor: do things to the predictions before returning
5251

5352
**Target audiences:**
5453

55-
- Basic. Has data, calls forecaster with default arguments.
56-
- Intermediate. Wants to examine changes to the arguments, take
57-
advantage of built in flexibility.
58-
- Advanced. Wants to write their own forecasters. Maybe willing to
59-
build up from some components.
54+
- Basic. Has data, calls forecaster with default arguments.
55+
- Intermediate. Wants to examine changes to the arguments, take
56+
advantage of built in flexibility.
57+
- Advanced. Wants to write their own forecasters. Maybe willing to build
58+
up from some components.
6059

6160
The Advanced user should find their task to be relatively easy. Examples
6261
of these tasks are illustrated in the [vignettes and
@@ -71,7 +70,7 @@ The package comes with some built-in historical data for illustration,
7170
but up-to-date versions of this could be downloaded with the
7271
[`{epidatr}` package](https://cmu-delphi.github.io/epidatr/) and
7372
processed using
74-
[`{epiprocess}`](https://cmu-delphi.github.io/epiprocess/).\[1\]
73+
[`{epiprocess}`](https://cmu-delphi.github.io/epiprocess/).[^1]
7574

7675
``` r
7776
library(epipredict)
@@ -114,7 +113,7 @@ two_week_ahead <- arx_forecaster(
114113
two_week_ahead
115114
#> ══ A basic forecaster of type ARX Forecaster ═══════════════════════════════
116115
#>
117-
#> This forecaster was fit on 2024-01-29 15:10:01.
116+
#> This forecaster was fit on 2024-11-11 11:38:31.
118117
#>
119118
#> Training data was an <epi_df> with:
120119
#> • Geography: state,
@@ -207,7 +206,7 @@ through the end of 2021 for the 14th of January 2022. A prediction for
207206
the death rate per 100K inhabitants is available for every state
208207
(`geo_value`) along with a 90% predictive interval.
209208

210-
1. Other epidemiological signals for non-Covid related illnesses are
209+
[^1]: Other epidemiological signals for non-Covid related illnesses are
211210
also available with
212211
[`{epidatr}`](https://github.com/cmu-delphi/epidatr) which
213212
interfaces directly to Delphi’s [Epidata

_pkgdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ home:
3737
- text: The epiprocess package
3838
href: https://cmu-delphi.github.io/epiprocess/
3939
sidebar:
40-
structure: [links, license, community, citation, authors, related, dev]
40+
structure: [links, license, community, citation, authors, dev, related]
4141
components:
4242
related:
4343
title: Delphi packages and resources

vignettes/epipredict.Rmd

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ library(dplyr)
2121
library(parsnip)
2222
library(workflows)
2323
library(recipes)
24-
library(epiprocess)
2524
library(epipredict)
2625
```
2726

@@ -226,17 +225,15 @@ symmetrized). Here, we used 23 quantiles, but one can grab a particular
226225
quantile,
227226

228227
```{r q1}
229-
head(quantile(out_q$predictions$.pred_distn, p = .4))
228+
round(head(quantile(out_q$predictions$.pred_distn, p = .4)), 3)
230229
```
231230

232231
or extract the entire distribution into a "long" `epi_df` with `quantile_levels`
233232
being the probability and `values` being the value associated to that quantile.
234233

235234
```{r q2}
236235
out_q$predictions %>%
237-
# first create a "nested" list-column
238-
mutate(.pred_distn = nested_quantiles(.pred_distn)) %>%
239-
unnest(.pred_distn) # then unnest it
236+
pivot_quantiles_longer(.pred_distn)
240237
```
241238

242239
Additional simple adjustments to the basic forecaster can be made using the
@@ -262,26 +259,32 @@ package:
262259

263260
```{r ranger, warning = FALSE}
264261
out_rf <- arx_forecaster(
265-
jhu, "death_rate", c("case_rate", "death_rate"),
266-
rand_forest(mode = "regression")
262+
jhu,
263+
outcome = "death_rate",
264+
predictors = c("case_rate", "death_rate"),
265+
trainer = rand_forest(mode = "regression")
267266
)
268267
```
269268

270269
Or boosted regression trees with `{xgboost}`:
271270

272271
```{r xgboost, warning = FALSE}
273272
out_gb <- arx_forecaster(
274-
jhu, "death_rate", c("case_rate", "death_rate"),
275-
boost_tree(mode = "regression", trees = 20)
273+
jhu,
274+
outcome = "death_rate",
275+
predictors = c("case_rate", "death_rate"),
276+
trainer = boost_tree(mode = "regression", trees = 20)
276277
)
277278
```
278279

279280
Or quantile regression, using our custom forecasting engine `quantile_reg()`:
280281

281282
```{r quantreg, warning = FALSE}
282283
out_qr <- arx_forecaster(
283-
jhu, "death_rate", c("case_rate", "death_rate"),
284-
quantile_reg()
284+
jhu,
285+
outcome = "death_rate",
286+
predictors = c("case_rate", "death_rate"),
287+
trainer = quantile_reg()
285288
)
286289
```
287290

0 commit comments

Comments
 (0)