From c5ccdb4d68c7006a5ce9c61ffe0b9d12ff527f76 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Tue, 17 Oct 2023 13:08:49 -0700 Subject: [PATCH 1/7] update news --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 92c79d9..4ab3dae 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # embed (development version) -* `step_collapse_stringdist()` will now return predictors as factors. +* `step_collapse_stringdist()` will now return predictors as factors. (#204) # embed 1.1.2 From 5848310300df042e9d358f7a20a8d4d2a623df58 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Tue, 17 Oct 2023 13:29:55 -0700 Subject: [PATCH 2/7] update revdep results --- revdep/README.md | 55 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/revdep/README.md b/revdep/README.md index d748baa..f80d9db 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -1,38 +1,37 @@ # Platform -|field |value | -|:--------|:------------------------------------------------------------------------------------------| -|version |R version 4.3.0 (2023-04-21) | -|os |macOS Ventura 13.5 | -|system |aarch64, darwin20 | -|ui |RStudio | -|language |(EN) | -|collate |en_US.UTF-8 | -|ctype |en_US.UTF-8 | -|tz |America/Los_Angeles | -|date |2023-08-14 | -|rstudio |2023.09.0-daily+310 Desert Sunflower (desktop) | -|pandoc |3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown) | +|field |value | +|:--------|:------------------------------------------------------------| +|version |R version 4.3.1 (2023-06-16) | +|os |macOS Ventura 13.6 | +|system |aarch64, darwin20 | +|ui |X11 | +|language |(EN) | +|collate |en_US.UTF-8 | +|ctype |en_US.UTF-8 | +|tz |America/Los_Angeles | +|date |2023-10-17 | +|pandoc |3.1.3 @ /Users/emilhvitfeldt/miniforge3/bin/ (via rmarkdown) | # Dependencies |package |old |new |Δ | |:------------|:----------|:----------|:--| -|embed |1.1.1 |1.1.1.9000 |* | +|embed |1.1.2 |1.1.2.9000 |* | |backports |1.4.1 |1.4.1 | | |base64enc |0.1-3 |0.1-3 | | |BH |1.81.0-1 |1.81.0-1 | | |cli |3.6.1 |3.6.1 | | |clock |0.7.0 |0.7.0 | | -|config |0.3.1 |0.3.1 | | +|config |0.3.2 |0.3.2 | | |cpp11 |0.4.6 |0.4.6 | | |data.table |1.14.8 |1.14.8 | | |diagram |1.6.5 |1.6.5 | | |digest |0.6.33 |0.6.33 | | -|dplyr |1.1.2 |1.1.2 | | -|dqrng |0.3.0 |0.3.0 | | +|dplyr |1.1.3 |1.1.3 | | +|dqrng |0.3.1 |0.3.1 | | |ellipsis |0.3.2 |0.3.2 | | -|fansi |1.0.4 |1.0.4 | | +|fansi |1.0.5 |1.0.5 | | |FNN |1.1.3.2 |1.1.3.2 | | |furrr |0.3.1 |0.3.1 | | |future |1.33.0 |1.33.0 | | @@ -46,11 +45,11 @@ |ipred |0.9-14 |0.9-14 | | |irlba |2.3.5.1 |2.3.5.1 | | |jsonlite |1.8.7 |1.8.7 | | -|keras |2.11.1 |2.11.1 | | +|keras |2.13.0 |2.13.0 | | |lava |1.7.2.1 |1.7.2.1 | | |lifecycle |1.0.3 |1.0.3 | | |listenv |0.9.0 |0.9.0 | | -|lubridate |1.9.2 |1.9.2 | | +|lubridate |1.9.3 |1.9.3 | | |magrittr |2.0.3 |2.0.3 | | |numDeriv |2016.8-1.1 |2016.8-1.1 | | |parallelly |1.36.0 |1.36.0 | | @@ -58,7 +57,7 @@ |pkgconfig |2.0.3 |2.0.3 | | |png |0.1-8 |0.1-8 | | |processx |3.8.2 |3.8.2 | | -|prodlim |2023.03.31 |2023.03.31 | | +|prodlim |2023.08.28 |2023.08.28 | | |progressr |0.14.0 |0.14.0 | | |ps |1.7.5 |1.7.5 | | |purrr |1.0.2 |1.0.2 | | @@ -68,19 +67,19 @@ |RcppAnnoy |0.0.21 |0.0.21 | | |RcppProgress |0.4.2 |0.4.2 | | |RcppTOML |0.2.2 |0.2.2 | | -|recipes |1.0.7 |1.0.7 | | -|reticulate |1.31 |1.31 | | +|recipes |1.0.8 |1.0.8 | | +|reticulate |1.34.0 |1.34.0 | | |rlang |1.1.1 |1.1.1 | | |rprojroot |2.0.3 |2.0.3 | | -|rsample |1.1.1 |1.1.1 | | +|rsample |1.2.0 |1.2.0 | | |rstudioapi |0.15.0 |0.15.0 | | |shape |1.4.6 |1.4.6 | | |sitmo |2.0.2 |2.0.2 | | -|slider |0.3.0 |0.3.0 | | +|slider |0.3.1 |0.3.1 | | |SQUAREM |2021.1 |2021.1 | | |stringi |1.7.12 |1.7.12 | | |stringr |1.5.0 |1.5.0 | | -|tensorflow |2.11.0 |2.11.0 | | +|tensorflow |2.14.0 |2.14.0 | | |tfautograph |0.3.2 |0.3.2 | | |tfruns |1.5.1 |1.5.1 | | |tibble |3.2.1 |3.2.1 | | @@ -91,10 +90,10 @@ |tzdb |0.4.0 |0.4.0 | | |utf8 |1.2.3 |1.2.3 | | |uwot |0.1.16 |0.1.16 | | -|vctrs |0.6.3 |0.6.3 | | +|vctrs |0.6.4 |0.6.4 | | |warp |0.2.0 |0.2.0 | | |whisker |0.4.1 |0.4.1 | | -|withr |2.5.0 |2.5.0 | | +|withr |2.5.1 |2.5.1 | | |yaml |2.3.7 |2.3.7 | | |zeallot |0.1.0 |0.1.0 | | From 97808075583e1c4f3673cca64b783c556ffd1fe0 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Fri, 20 Oct 2023 15:24:29 -0700 Subject: [PATCH 3/7] don't export is_tf_available() --- NAMESPACE | 1 - R/embed.R | 12 +++--------- R/feature_hash.R | 4 ++-- _pkgdown.yml | 1 - man/is_tf_available.Rd | 17 ----------------- man/step_embed.Rd | 2 +- man/step_feature_hash.Rd | 2 +- tests/testthat/test-embed.R | 22 +++++++++++----------- tests/testthat/test-helpers.R | 2 +- 9 files changed, 19 insertions(+), 44 deletions(-) delete mode 100644 man/is_tf_available.Rd diff --git a/NAMESPACE b/NAMESPACE index 65d1e2a..6c09f61 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -81,7 +81,6 @@ S3method(tunable,step_woe) export(add_woe) export(dictionary) export(embed_control) -export(is_tf_available) export(required_pkgs) export(step_collapse_cart) export(step_collapse_stringdist) diff --git a/R/embed.R b/R/embed.R index cd0c411..bae02c1 100644 --- a/R/embed.R +++ b/R/embed.R @@ -122,7 +122,7 @@ #' "Concatenate Embeddings for Categorical Variables with Keras" #' \url{https://flovv.github.io/Embeddings_with_keras_part2/} #' -#' @examplesIf is_tf_available() && rlang::is_installed("modeldata") +#' @examplesIf embed:::is_tf_available() && rlang::is_installed("modeldata") #' data(grants, package = "modeldata") #' #' set.seed(1) @@ -150,7 +150,7 @@ step_embed <- skip = FALSE, id = rand_id("embed")) { # warm start for tf to avoid a bug in tensorflow - is_tf_available() + embed:::is_tf_available() if (is.null(outcome)) { rlang::abort("Please list a variable in `outcome`") @@ -254,7 +254,7 @@ prep.step_embed <- function(x, training, info = NULL, ...) { } is_tf_2 <- function() { - if (!is_tf_available()) { + if (!embed:::is_tf_available()) { rlang::abort( c( "tensorflow could now be found.", @@ -531,12 +531,6 @@ class2ind <- function(x) { y } -#' Test to see if tensorflow is available -#' -#' @return A logical -#' @examples -#' is_tf_available() -#' @export is_tf_available <- function() { if (!rlang::is_installed("tensorflow")) { return(FALSE) diff --git a/R/feature_hash.R b/R/feature_hash.R index 1f0acc8..68f7097 100644 --- a/R/feature_hash.R +++ b/R/feature_hash.R @@ -50,7 +50,7 @@ #' Approach for Predictive Models_. CRC/Chapman Hall #' \url{https://bookdown.org/max/FES/encoding-predictors-with-many-categories.html} #' @seealso [recipes::step_dummy()], [recipes::step_zv()] -#' @examplesIf is_tf_available() && rlang::is_installed("modeldata") +#' @examplesIf embed:::is_tf_available() && rlang::is_installed("modeldata") #' data(grants, package = "modeldata") #' rec <- #' recipe(class ~ sponsor_code, data = grants_other) %>% @@ -94,7 +94,7 @@ step_feature_hash <- } # warm start for tf to avoid a bug in tensorflow - is_tf_available() + embed:::is_tf_available() add_step( recipe, diff --git a/_pkgdown.yml b/_pkgdown.yml index b664902..9586f21 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -38,7 +38,6 @@ reference: - title: miscellaneous contents: - dictionary - - is_tf_available - title: Tidy Methods contents: - tidy.recipe diff --git a/man/is_tf_available.Rd b/man/is_tf_available.Rd deleted file mode 100644 index 3140d7b..0000000 --- a/man/is_tf_available.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/embed.R -\name{is_tf_available} -\alias{is_tf_available} -\title{Test to see if tensorflow is available} -\usage{ -is_tf_available() -} -\value{ -A logical -} -\description{ -Test to see if tensorflow is available -} -\examples{ -is_tf_available() -} diff --git a/man/step_embed.Rd b/man/step_embed.Rd index c123c3c..f35912e 100644 --- a/man/step_embed.Rd +++ b/man/step_embed.Rd @@ -172,7 +172,7 @@ The underlying operation does not allow for case weights. } \examples{ -\dontshow{if (is_tf_available() && rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (embed:::is_tf_available() && rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} data(grants, package = "modeldata") set.seed(1) diff --git a/man/step_feature_hash.Rd b/man/step_feature_hash.Rd index fb79793..9ea394a 100644 --- a/man/step_feature_hash.Rd +++ b/man/step_feature_hash.Rd @@ -93,7 +93,7 @@ The underlying operation does not allow for case weights. } \examples{ -\dontshow{if (is_tf_available() && rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (embed:::is_tf_available() && rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} data(grants, package = "modeldata") rec <- recipe(class ~ sponsor_code, data = grants_other) \%>\% diff --git a/tests/testthat/test-embed.R b/tests/testthat/test-embed.R index 3b64a11..3e78c8c 100644 --- a/tests/testthat/test-embed.R +++ b/tests/testthat/test-embed.R @@ -10,7 +10,7 @@ withr::local_envvar(TF_CPP_MIN_LOG_LEVEL = "2") test_that("factor encoded predictor", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) class_test <- recipe(x2 ~ ., data = ex_dat) %>% step_embed(x3, outcome = vars(x2), options = embed_control(verbose = 0), id = "id") %>% @@ -80,7 +80,7 @@ test_that("factor encoded predictor", { test_that("character encoded predictor", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) class_test <- recipe(x2 ~ ., data = ex_dat_ch) %>% step_embed(x3, outcome = vars(x2), options = embed_control(verbose = 0)) %>% @@ -148,7 +148,7 @@ test_that("character encoded predictor", { test_that("factor encoded predictor", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) class_test <- recipe(x1 ~ ., data = ex_dat) %>% step_embed(x3, outcome = vars(x1), options = embed_control(verbose = 0)) %>% @@ -217,7 +217,7 @@ test_that("factor encoded predictor", { test_that("character encoded predictor", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) class_test <- recipe(x1 ~ ., data = ex_dat_ch) %>% step_embed(x3, outcome = vars(x1), num_terms = 5, options = embed_control(verbose = 0)) %>% @@ -285,7 +285,7 @@ test_that("character encoded predictor", { test_that("bad args", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) three_class <- iris three_class$fac <- rep(letters[1:3], 50) @@ -301,7 +301,7 @@ test_that("bad args", { test_that("check_name() is used", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) dat <- ex_dat dat$x3_embed_1 <- dat$x3 @@ -334,7 +334,7 @@ test_that("tunable", { test_that("bake method errors when needed non-standard role columns are missing", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) rec <- recipe(x2 ~ ., data = ex_dat) %>% step_embed( x3, @@ -355,7 +355,7 @@ test_that("bake method errors when needed non-standard role columns are missing" test_that("empty printing", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) rec <- recipe(mpg ~ ., mtcars) rec <- step_embed(rec, outcome = vars(mpg)) @@ -400,7 +400,7 @@ test_that("empty selection tidy method works", { test_that("keep_original_cols works", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) new_names <- c("x2", "x3_embed_1", "x3_embed_2") @@ -431,7 +431,7 @@ test_that("keep_original_cols works", { test_that("keep_original_cols - can prep recipes with it missing", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) rec <- recipe(x2 ~ x3, data = ex_dat) %>% step_embed(x3, outcome = vars(x2), options = embed_control(verbose = 0)) @@ -450,7 +450,7 @@ test_that("keep_original_cols - can prep recipes with it missing", { test_that("printing", { skip_on_cran() - skip_if(!is_tf_available()) + skip_if(!embed:::is_tf_available()) rec <- recipe(x2 ~ ., data = ex_dat_ch) %>% step_embed(x3, outcome = vars(x2)) diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index 466a46c..f05a6de 100644 --- a/tests/testthat/test-helpers.R +++ b/tests/testthat/test-helpers.R @@ -2,4 +2,4 @@ library(embed) library(dplyr) library(testthat) -is_tf_available() +embed:::is_tf_available() From 17dcca5379d33c549897c6a85fa0df34ec2e33c7 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Wed, 25 Oct 2023 10:47:00 -0700 Subject: [PATCH 4/7] typo --- NEWS.md | 2 ++ R/lencode_glm.R | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 4ab3dae..b83ae06 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ * `step_collapse_stringdist()` will now return predictors as factors. (#204) +* Fixed regression from 1.1.2 in `step_lencode_glm()` where it couldn't be used on multiple columns. + # embed 1.1.2 ## Improvements diff --git a/R/lencode_glm.R b/R/lencode_glm.R index b5faa5f..f4713d4 100644 --- a/R/lencode_glm.R +++ b/R/lencode_glm.R @@ -203,7 +203,7 @@ bake.step_lencode_glm <- function(object, new_data, ...) { for (col_name in col_names) { new_data[[col_name]] <- map_glm_coef( dat = new_data[, col_name], # map_glm_coef() expects a tibble - mapping = object$mapping[[col_names]] + mapping = object$mapping[[col_name]] ) } From 226dc723f0bba981db2d455684828ce4fcfa0a42 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Wed, 25 Oct 2023 12:19:17 -0700 Subject: [PATCH 5/7] add is_cran_check() --- R/aaa.R | 9 +++++++++ R/embed.R | 6 +++--- R/feature_hash.R | 4 ++-- man/step_embed.Rd | 2 +- man/step_feature_hash.Rd | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/R/aaa.R b/R/aaa.R index 37bc096..1a4592c 100644 --- a/R/aaa.R +++ b/R/aaa.R @@ -12,4 +12,13 @@ utils::globalVariables( ) ) +# adapted from ps:::is_cran_check() +is_cran_check <- function() { + if (identical(Sys.getenv("NOT_CRAN"), "true")) { + FALSE + } + else { + Sys.getenv("_R_CHECK_PACKAGE_NAME_", "") != "" + } +} # nocov end diff --git a/R/embed.R b/R/embed.R index bae02c1..5ae9199 100644 --- a/R/embed.R +++ b/R/embed.R @@ -122,7 +122,7 @@ #' "Concatenate Embeddings for Categorical Variables with Keras" #' \url{https://flovv.github.io/Embeddings_with_keras_part2/} #' -#' @examplesIf embed:::is_tf_available() && rlang::is_installed("modeldata") +#' @examplesIf !embed:::is_cran_check() && rlang::is_installed("modeldata") #' data(grants, package = "modeldata") #' #' set.seed(1) @@ -150,7 +150,7 @@ step_embed <- skip = FALSE, id = rand_id("embed")) { # warm start for tf to avoid a bug in tensorflow - embed:::is_tf_available() + is_tf_available() if (is.null(outcome)) { rlang::abort("Please list a variable in `outcome`") @@ -254,7 +254,7 @@ prep.step_embed <- function(x, training, info = NULL, ...) { } is_tf_2 <- function() { - if (!embed:::is_tf_available()) { + if (!is_tf_available()) { rlang::abort( c( "tensorflow could now be found.", diff --git a/R/feature_hash.R b/R/feature_hash.R index 68f7097..c33eb82 100644 --- a/R/feature_hash.R +++ b/R/feature_hash.R @@ -50,7 +50,7 @@ #' Approach for Predictive Models_. CRC/Chapman Hall #' \url{https://bookdown.org/max/FES/encoding-predictors-with-many-categories.html} #' @seealso [recipes::step_dummy()], [recipes::step_zv()] -#' @examplesIf embed:::is_tf_available() && rlang::is_installed("modeldata") +#' @examplesIf !embed:::is_cran_check() && rlang::is_installed("modeldata") #' data(grants, package = "modeldata") #' rec <- #' recipe(class ~ sponsor_code, data = grants_other) %>% @@ -94,7 +94,7 @@ step_feature_hash <- } # warm start for tf to avoid a bug in tensorflow - embed:::is_tf_available() + is_tf_available() add_step( recipe, diff --git a/man/step_embed.Rd b/man/step_embed.Rd index f35912e..d8ca784 100644 --- a/man/step_embed.Rd +++ b/man/step_embed.Rd @@ -172,7 +172,7 @@ The underlying operation does not allow for case weights. } \examples{ -\dontshow{if (embed:::is_tf_available() && rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!embed:::is_cran_check() && rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} data(grants, package = "modeldata") set.seed(1) diff --git a/man/step_feature_hash.Rd b/man/step_feature_hash.Rd index 9ea394a..18bfe7f 100644 --- a/man/step_feature_hash.Rd +++ b/man/step_feature_hash.Rd @@ -93,7 +93,7 @@ The underlying operation does not allow for case weights. } \examples{ -\dontshow{if (embed:::is_tf_available() && rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!embed:::is_cran_check() && rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} data(grants, package = "modeldata") rec <- recipe(class ~ sponsor_code, data = grants_other) \%>\% From 6b5fb69817e99ca174e5a11a1807325c46b116a5 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Sat, 28 Oct 2023 15:56:25 -0700 Subject: [PATCH 6/7] Increment version number to 1.1.3 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f49cce2..5cdea26 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: embed Title: Extra Recipes for Encoding Predictors -Version: 1.1.2.9000 +Version: 1.1.3 Authors@R: c( person("Emil", "Hvitfeldt", , "emil.hvitfeldt@posit.co", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-0679-1945")), diff --git a/NEWS.md b/NEWS.md index b83ae06..0f109ed 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# embed (development version) +# embed 1.1.3 * `step_collapse_stringdist()` will now return predictors as factors. (#204) From c82fcdd8bf280f1e75029f5ef9e38d4783d8d1df Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Sat, 28 Oct 2023 16:46:35 -0700 Subject: [PATCH 7/7] Increment version number to 1.1.3.9000 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5cdea26..5167a80 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: embed Title: Extra Recipes for Encoding Predictors -Version: 1.1.3 +Version: 1.1.3.9000 Authors@R: c( person("Emil", "Hvitfeldt", , "emil.hvitfeldt@posit.co", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-0679-1945")), diff --git a/NEWS.md b/NEWS.md index 0f109ed..6392caf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# embed (development version) + # embed 1.1.3 * `step_collapse_stringdist()` will now return predictors as factors. (#204)