-
Notifications
You must be signed in to change notification settings - Fork 10
step_epi_naomit branched off frosting. #79
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
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f7db957
step_epi_naomit branched off frosting.
kenmawer 9b50d40
Improved inheritance check.
kenmawer 2b16ec9
Only a byproduct of running devtools::check()
kenmawer eebc920
Merge branch 'frosting' into km-step_epi_naomit-good
kenmawer f319722
All tests pass
kenmawer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#' Unified NA omission wrapper function for recipes | ||
#' | ||
#' @param recipe Recipe to be used for omission steps | ||
#' | ||
#' @return Omits NA's from both predictors and outcomes at training time | ||
#' to fit the model. Also only omits associated predictors and not | ||
#' outcomes at prediction time due to lack of response and avoidance | ||
#' of data loss. | ||
#' @export | ||
#' @examples | ||
#' case_death_rate_subset %>% | ||
#' epi_recipe() %>% | ||
#' step_epi_naomit() | ||
|
||
step_epi_naomit <- function(recipe) { | ||
stopifnot("recipe" %in% class(recipe)) | ||
recipe %>% | ||
recipes::step_naomit(all_predictors()) %>% | ||
recipes::step_naomit(all_outcomes(), skip = TRUE) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
library(dplyr) | ||
library(epiprocess) | ||
library(parsnip) | ||
library(workflows) | ||
|
||
# Random generated dataset | ||
x <- tibble(geo_value = rep("nowhere",200), | ||
time_value = as.Date("2021-01-01") + 0:199, | ||
case_rate = 1:200, | ||
death_rate = 1:200) %>% | ||
as_epi_df() | ||
|
||
# Preparing the datasets to be used for comparison | ||
r <- epi_recipe(x) %>% | ||
step_epi_ahead(death_rate, ahead = 7) %>% | ||
step_epi_lag(death_rate, lag = c(0,7,14)) | ||
|
||
test_that("Argument must be a recipe", { | ||
expect_error(step_epi_naomit(x)) | ||
}) | ||
|
||
z1 <- step_epi_naomit(r) | ||
z2 <- r %>% | ||
step_naomit(all_predictors()) %>% | ||
step_naomit(all_outcomes(), skip = TRUE) | ||
|
||
# Checks the behaviour of a step function, omitting the quosure and id that | ||
# differ from one another, even with identical behaviour | ||
behav <- function(recipe,step_num) recipe$steps[[step_num]][-1][-5] | ||
# Checks the class type of an object | ||
step_class <- function(recipe,step_num) class(recipe$steps[step_num]) | ||
|
||
test_that("Check that both functions behave the same way", { | ||
expect_identical(behav(z1,3),behav(z2,3)) | ||
expect_identical(behav(z1,4),behav(z2,4)) | ||
expect_identical(step_class(z1,3),step_class(z2,3)) | ||
expect_identical(step_class(z1,4),step_class(z2,4)) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rerun
devtools::document
and the Rd files for create_layer and new_epi_recipe_blueprint haven't been deleted. For the former, it claims that it comes fromcreate-layer.R
.Also, I updated the second comment.