Skip to content

Commit

Permalink
Transition from modeldata::okc to modeldata::Sacramento (#219)
Browse files Browse the repository at this point in the history
* transition `modeldata::okc` to `modeldata::Sacramento`

* add NEWS bullet

* Move and tweak NEWS bullet

Co-authored-by: DavisVaughan <davis@rstudio.com>
  • Loading branch information
simonpcouch and DavisVaughan authored May 9, 2022
1 parent 77b3b44 commit 7f4db7c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# butcher (development version)

* Transitioned unit tests to make use of `modeldata::Sacramento` rather than
`modeldata::okc` in anticipation of `okc`'s deprecation in an upcoming
release of modeldata (@simonpcouch, #219).

* Removed fastICA and NMF from Suggests. fastICA requires R >= 4.0.0 now, and
NMF is often hard to install and was only used for one test (#201).

Expand All @@ -9,7 +13,7 @@
* Removed `axe_fitted()` and `axe_ctrl()` for xgboost, because these methods
caused problems for prediction (#218).

* Added butcher methods for `glm()` (#212).
* Added butcher methods for `glm()` (#212).

# butcher 0.1.5

Expand Down
40 changes: 21 additions & 19 deletions tests/testthat/test-recipe.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ credit_tr <- training(train_test_split)

# Additional data sets used
data(covers)
data(okc)
data(Sacramento)

# Test helpers
terms_empty_env <- function(axed, step_number) {
Expand Down Expand Up @@ -241,26 +241,26 @@ test_that("recipe + step_date + axe_env() works", {
})

test_that("recipe + step_dummy + axe_env() works", {
rec <- recipe(~ diet + age + height, data = okc) %>%
step_dummy(diet)
rec <- recipe(~ city + sqft + price, data = Sacramento) %>%
step_dummy(city)
x <- axe_env(rec)
terms_empty_env(x, 1)
})

test_that("recipe + step_string2factor + axe_env() works", {
rec <- recipe(~ diet + age + height, data = okc) %>%
step_string2factor(diet)
rec <- recipe(~ city + sqft + price, data = Sacramento) %>%
step_factor2string(city) %>%
step_string2factor(city)
x <- axe_env(rec)
terms_empty_env(x, 1)
terms_empty_env(x, 2)
})

test_that("recipe + step_factor2string + axe_env() works", {
rec <- recipe(~ diet + age + height, data = okc) %>%
step_string2factor(diet) %>%
step_factor2string(diet)
rec <- recipe(~ city + sqft + price, data = Sacramento) %>%
step_factor2string(city)
x <- axe_env(rec)
terms_empty_env(x, 1)
terms_empty_env(x, 2)
})

test_that("recipe + step_holiday + axe_env() works", {
Expand All @@ -272,19 +272,21 @@ test_that("recipe + step_holiday + axe_env() works", {
})

test_that("recipe + step_integer + axe_env() works", {
rec <- recipe(Class ~ ., data = okc) %>%
rec <- Sacramento %>%
dplyr::select(type, sqft, price, beds) %>%
recipe(type ~ .) %>%
step_integer(all_predictors())
x <- axe_env(rec)
terms_empty_env(x, 1)
})

test_that("recipe + step_novel + axe_env() works", {
okc_tr <- okc[1:30000,]
okc_te <- okc[30001:30006,]
okc_te$diet[3] <- "cannibalism"
okc_te$diet[4] <- "vampirism"
rec <- recipe(Class ~ ., data = okc_tr) %>%
step_novel(diet, location)
sacr_tr <- Sacramento[1:500,] %>% dplyr::mutate(city = as.character(city))
sacr_te <- Sacramento[501:nrow(Sacramento),] %>% dplyr::mutate(city = as.character(city))
sacr_te$city[3] <- "boopville"
sacr_te$city[4] <- "beeptown"
rec <- recipe(type ~ ., data = sacr_tr) %>%
step_novel(city, zip)
x <- axe_env(rec)
terms_empty_env(x, 1)
})
Expand Down Expand Up @@ -317,8 +319,8 @@ test_that("recipe + step_ordinalscore + axe_env() works", {
})

test_that("recipe + step_other + axe_env() works", {
rec <- recipe(~ diet + location, data = okc) %>%
step_other(diet, location, threshold = .1, other = "other values")
rec <- recipe(~ city + zip, data = Sacramento) %>%
step_other(city, zip, threshold = .1, other = "other values")
x <- axe_env(rec)
terms_empty_env(x, 1)
})
Expand Down Expand Up @@ -584,7 +586,7 @@ test_that("recipe + step_impute_mode + axe_env() works", {
})

test_that("recipe + step_naomit + axe_env() works", {
rec <- recipe( ~ ., data = okc) %>%
rec <- recipe( ~ ., data = Sacramento) %>%
step_naomit(all_predictors())
x <- axe_env(rec)
terms_empty_env(x, 1)
Expand Down

0 comments on commit 7f4db7c

Please sign in to comment.