1
1
# ' Limits the size of the training window to the most recent observations
2
2
# '
3
- # ' `step_training_window2 ` creates a *specification* of a recipe step that
3
+ # ' `step_epi_training_window ` creates a *specification* of a recipe step that
4
4
# ' limits the size of the training window to the `n_recent` most recent
5
5
# ' observations in `time_value` per group, where the groups are formed
6
6
# ' based on the remaining `epi_keys`.
40
40
# ' as_epi_df()
41
41
# '
42
42
# ' epi_recipe(y ~ x, data = tib) %>%
43
- # ' step_training_window2 (n_recent = 3) %>%
43
+ # ' step_epi_training_window (n_recent = 3) %>%
44
44
# ' prep(tib) %>%
45
45
# ' bake(new_data = NULL)
46
46
# '
47
47
# ' epi_recipe(y ~ x, data = tib) %>%
48
48
# ' step_epi_naomit() %>%
49
- # ' step_training_window2 (n_recent = 3) %>%
49
+ # ' step_epi_training_window (n_recent = 3) %>%
50
50
# ' prep(tib) %>%
51
51
# ' bake(new_data = NULL)
52
- step_training_window2 <-
52
+ step_epi_training_window <-
53
53
function (recipe ,
54
54
role = NA ,
55
55
n_recent = 50 ,
56
56
seasonal = FALSE ,
57
57
seasonal_forward_window = 14 ,
58
58
seasonal_backward_window = 35 ,
59
59
epi_keys = NULL ,
60
- id = rand_id(" training_window2 " )) {
60
+ id = rand_id(" epi_training_window " )) {
61
61
epipredict ::: arg_is_scalar(n_recent , id , seasonal , seasonal_forward_window , seasonal_backward_window )
62
62
epipredict ::: arg_is_pos(n_recent , seasonal_forward_window , seasonal_backward_window )
63
63
if (is.finite(n_recent )) epipredict ::: arg_is_pos_int(n_recent )
64
64
epipredict ::: arg_is_chr(id )
65
65
epipredict ::: arg_is_chr(epi_keys , allow_null = TRUE )
66
66
add_step(
67
67
recipe ,
68
- step_training_window2_new (
68
+ step_epi_training_window_new (
69
69
role = role ,
70
70
trained = FALSE ,
71
71
n_recent = n_recent ,
@@ -79,10 +79,10 @@ step_training_window2 <-
79
79
)
80
80
}
81
81
82
- step_training_window2_new <-
82
+ step_epi_training_window_new <-
83
83
function (role , trained , n_recent , seasonal , seasonal_forward_window , seasonal_backward_window , epi_keys , skip , id ) {
84
84
step(
85
- subclass = " training_window2 " ,
85
+ subclass = " epi_training_window " ,
86
86
role = role ,
87
87
trained = trained ,
88
88
n_recent = n_recent ,
@@ -96,13 +96,13 @@ step_training_window2_new <-
96
96
}
97
97
98
98
# ' @export
99
- prep.step_training_window2 <- function (x , training , info = NULL , ... ) {
99
+ prep.step_epi_training_window <- function (x , training , info = NULL , ... ) {
100
100
ekt <- epipredict ::: epi_keys_only(training )
101
101
ek <- x $ epi_keys %|| % ekt %|| % character (0L )
102
102
103
103
hardhat :: validate_column_names(training , ek )
104
104
105
- step_training_window2_new (
105
+ step_epi_training_window_new (
106
106
role = x $ role ,
107
107
trained = TRUE ,
108
108
n_recent = x $ n_recent ,
@@ -116,7 +116,7 @@ prep.step_training_window2 <- function(x, training, info = NULL, ...) {
116
116
}
117
117
118
118
# ' @export
119
- bake.step_training_window2 <- function (object , new_data , ... ) {
119
+ bake.step_epi_training_window <- function (object , new_data , ... ) {
120
120
hardhat :: validate_column_names(new_data , object $ epi_keys )
121
121
122
122
if (object $ n_recent < Inf ) {
@@ -155,7 +155,7 @@ bake.step_training_window2 <- function(object, new_data, ...) {
155
155
}
156
156
157
157
# ' @export
158
- print.step_training_window2 <-
158
+ print.step_epi_training_window <-
159
159
function (x , width = max(20 , options()$ width - 30 ), ... ) {
160
160
if (x $ seasonal ) {
161
161
title <- " # of seasonal observations per key limited to:"
0 commit comments