Skip to content

km-kill-lags branched off frosting. #77

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

Merged
merged 31 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
25dca65
km-kill-lags branched off frosting.
kenmawer Jun 28, 2022
0c57340
Merge branch 'frosting' of https://github.com/cmu-delphi/epipredict i…
kenmawer Jun 30, 2022
7d52d6f
Documented changes.
kenmawer Jun 30, 2022
98d5e5b
Merge branch 'frosting' into km-kill-lags-good
kenmawer Jun 30, 2022
ac2cd0a
Still need to fix process to get proper get_test_data
kenmawer Jun 30, 2022
8b8c01c
Fixed issue of get_test_data.
kenmawer Jun 30, 2022
e978089
Refactored to fix errors. Note that warning comes from absence of def…
kenmawer Jun 30, 2022
25dcd5f
Merge branch 'frosting' of https://github.com/cmu-delphi/epipredict i…
kenmawer Jul 4, 2022
1d6994f
Updated functions to be consistent with style and changed those that …
kenmawer Jul 4, 2022
1115561
Integer error checking done at create time.
kenmawer Jul 4, 2022
85f3c55
Updated integer checking to work at creation time and replaced check …
kenmawer Jul 4, 2022
cb7c30a
Removed erroneous #TODO comment
kenmawer Jul 4, 2022
043618d
Deleted random code I put in on a test.
kenmawer Jul 4, 2022
a2acbdf
Merge pull request #85 from cmu-delphi/km-kill-lags-good2
kenmawer Jul 4, 2022
7ab49f2
A few updates. Note, however, that there is no unambiguous distinctio…
kenmawer Jul 5, 2022
4f2ba50
Added a class parameter that unambiguously distinguishes "lag" from "…
kenmawer Jul 5, 2022
0791458
Vague parameter `class` refactored to `intended_direction`.
kenmawer Jul 6, 2022
0712801
Solution involving swapping subclass vector arguments.
kenmawer Jul 6, 2022
752b650
Fixed print statement.
kenmawer Jul 6, 2022
b479077
This code runs properly.
kenmawer Jul 6, 2022
9bca965
Fixed issue of extra lines.
kenmawer Jul 6, 2022
02db5ff
Functions run, but print is brokoen
kenmawer Jul 6, 2022
b78a8c0
Merge branch 'frosting' of https://github.com/cmu-delphi/epipredict i…
kenmawer Jul 6, 2022
42b764d
Updated with pull; devtools::check() claims no errors or warnings, bu…
kenmawer Jul 6, 2022
88708ed
Tentative solution for printing to enable printing to work as it shou…
kenmawer Jul 6, 2022
d274eb1
Fixed erroneous printing.
kenmawer Jul 6, 2022
a64b7de
Merge branch 'frosting' of https://github.com/cmu-delphi/epipredict i…
kenmawer Jul 8, 2022
0f8a4bc
printing works, now we refactor
dajmcdon Jul 8, 2022
282793e
refactor done
dajmcdon Jul 8, 2022
4da3c9f
update the examples
dajmcdon Jul 8, 2022
e0fae3d
checks pass, improve file naming
dajmcdon Jul 8, 2022
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
9 changes: 3 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
S3method(apply_frosting,default)
S3method(apply_frosting,epi_workflow)
S3method(augment,epi_workflow)
S3method(bake,step_epi_ahead)
S3method(bake,step_epi_lag)
S3method(bake,step_epi_shift)
S3method(detect_layer,frosting)
S3method(detect_layer,workflow)
S3method(epi_keys,default)
Expand All @@ -17,12 +16,10 @@ S3method(extract_layers,frosting)
S3method(extract_layers,workflow)
S3method(predict,epi_workflow)
S3method(prep,epi_recipe)
S3method(prep,step_epi_ahead)
S3method(prep,step_epi_lag)
S3method(prep,step_epi_shift)
S3method(print,epi_workflow)
S3method(print,frosting)
S3method(print,step_epi_ahead)
S3method(print,step_epi_lag)
S3method(print,step_epi_shift)
S3method(refresh_blueprint,default_epi_recipe_blueprint)
S3method(run_mold,default_epi_recipe_blueprint)
S3method(slather,layer_naomit)
Expand Down
163 changes: 0 additions & 163 deletions R/epi_ahead.R

This file was deleted.

123 changes: 0 additions & 123 deletions R/epi_lag.R

This file was deleted.

20 changes: 10 additions & 10 deletions R/epi_shift.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
#'
#' This is a lower-level function. As such it performs no error checking.
#'
#' @param x Data frame. Variables to lag
#' @param lags List. Each list element is a vector of lags.
#' @param x Data frame. Variables to shift
#' @param shifts List. Each list element is a vector of shifts.
#' Negative values produce leads. The list should have the same
#' length as the number of columns in `x`.
#' @param time_value Vector. Same length as `x` giving time stamps.
#' @param keys Data frame, vector, or `NULL`. Additional grouping vars.
#' @param out_name Chr. The output list will use this as a prefix.
#'
#' @return a list of tibbles
epi_shift <- function(x, lags, time_value, keys = NULL, out_name = "x") {
epi_shift <- function(x, shifts, time_value, keys = NULL, out_name = "x") {
if (!is.data.frame(x)) x <- data.frame(x)
if (is.null(keys)) keys <- rep("empty", nrow(x))
p_in = ncol(x)
out_list <- tibble::tibble(i = 1:p_in, lag = lags) %>%
tidyr::unchop(lag) %>% # what is chop
out_list <- tibble::tibble(i = 1:p_in, shift = shifts) %>%
tidyr::unchop(shift) %>% # what is chop
dplyr::mutate(name = paste0(out_name, 1:nrow(.))) %>%
# One list element for each lagged feature
purrr::pmap(function(i, lag, name) {
# One list element for each shifted feature
purrr::pmap(function(i, shift, name) {
tibble(keys,
time_value = time_value + lag, # Shift back
time_value = time_value + shift, # Shift back
!!name := x[[i]])
})
if (is.data.frame(keys)) common_names <- c(names(keys), "time_value")
Expand All @@ -30,9 +30,9 @@ epi_shift <- function(x, lags, time_value, keys = NULL, out_name = "x") {
purrr::reduce(out_list, dplyr::full_join, by = common_names)
}

epi_shift_single <- function(x, col, lag_val, newname, key_cols) {
epi_shift_single <- function(x, col, shift_val, newname, key_cols) {
x %>%
dplyr::select(tidyselect::all_of(c(key_cols, col))) %>%
dplyr::mutate(time_value = time_value + lag_val) %>%
dplyr::mutate(time_value = time_value + shift_val) %>%
dplyr::rename(!!newname := col)
}
Loading