Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ jobs:
extra-packages: any::rcmdcheck
needs: check

- name: Install dev reticulate
run: pak::pkg_install('rstudio/reticulate')
- name: Install reticulate
run: pak::pkg_install('reticulate')
shell: Rscript {0}

- name: Install Miniconda
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# parsnip (development version)

## Bug Fixes

* Fixed a bug that errored when tidying a glmnet object with a penalty value greater than one (#1261).

# parsnip 1.3.0

## New Features
Expand Down
7 changes: 5 additions & 2 deletions R/tidy_glmnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ get_glmn_coefs <- function(x, penalty = 0.01) {
res <- tibble::as_tibble(res) %>% mutate(term = rn, penalty = penalty)
res <- dplyr::select(res, term, estimate, penalty)
if (is.list(res$estimate)) {
res$estimate <- purrr::map(res$estimate, ~ as_tibble(as.matrix(.x), rownames = "term"))
res$estimate <- purrr::map(
res$estimate,
~ as_tibble(as.matrix(.x), rownames = "term")
)
res <- tidyr::unnest(res, cols = c(estimate), names_repair = "minimal")
names(res) <- c("class", "term", "estimate", "penalty")
}
Expand All @@ -61,6 +64,6 @@ tidy_glmnet <- function(x, penalty = NULL, ..., call = caller_env()) {
if (is.null(penalty)) {
penalty <- x$spec$args$penalty
}
check_number_decimal(penalty, min = 0, max = 1, allow_null = TRUE, call = call)
check_number_decimal(penalty, min = 0, allow_null = TRUE, call = call)
get_glmn_coefs(x$fit, penalty = penalty)
}
11 changes: 2 additions & 9 deletions tests/testthat/_snaps/mlp_keras.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# keras execution, classification

Code
res <- parsnip::fit(hpc_keras, class ~ novar, data = hpc, control = ctrl)
Condition
Error:
! object 'novar' not found

# all keras activation functions

Code
Expand All @@ -14,4 +6,5 @@
Class ~ A + B, data = modeldata::two_class_dat)
Condition
Error in `parsnip::keras_mlp()`:
! `activation` should be one of: elu, exponential, gelu, hard_sigmoid, linear, relu, selu, sigmoid, softmax, softplus, softsign, swish, and tanh, not "invalid".
! `activation` should be one of: elu, exponential, gelu, hardsigmoid, linear, relu, selu, sigmoid, softmax, softplus, softsign, swish, and tanh, not "invalid".

Loading