@@ -519,16 +519,16 @@ such as `step_growth_rate()`.
519
519
520
520
``` {r class_recipe}
521
521
classifier_recipe <- epi_recipe(training_data) |>
522
- # Turn `time_value` into predictor
522
+ # Label `time_value` as predictor and do no other processing
523
523
add_role(time_value, new_role = "predictor") |>
524
- # Turn `geo_value_factor` into predictor by adding indicators for each value
524
+ # Use one-hot encoding on `geo_value_factor` and label each resulting column as a predictor
525
525
step_dummy(geo_value_factor) |>
526
- # Create and lag growth rate
526
+ # Create and lag `case_rate` growth rate
527
527
step_growth_rate(case_rate, role = "none", prefix = "gr_") |>
528
528
step_epi_lag(starts_with("gr_"), lag = c(0, 7, 14)) |>
529
529
step_epi_ahead(starts_with("gr_"), ahead = 7, role = "none") |>
530
- # Divide growth rate into 3 bins.
531
- # Note `recipes::step_cut()` has a bug, or we could use that here.
530
+ # Divide growth rate into 3 bins, and label as outcome variable
531
+ # Note `recipes::step_cut()` has a bug that prevents us from using it here
532
532
step_mutate(
533
533
response = cut(
534
534
ahead_7_gr_7_rel_change_case_rate,
@@ -539,7 +539,8 @@ classifier_recipe <- epi_recipe(training_data) |>
539
539
),
540
540
role = "outcome"
541
541
) |>
542
- # Drop unused columns, not strictly necessary
542
+ # Drop unused columns based on role assignments. This is not strictly
543
+ # necessary, as columns with roles unused in the model will be ignored anyway.
543
544
step_rm(has_role("none"), has_role("raw")) |>
544
545
step_epi_naomit()
545
546
```
0 commit comments