Skip to content

Commit bdb5a83

Browse files
committed
changes for #1261
1 parent b1e2ec2 commit bdb5a83

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# parsnip (development version)
22

3+
## Bug Fixes
4+
5+
* Fixed a bug that errored when tidying a glmnet object with a penalty value greater than one (#1261).
6+
37
# parsnip 1.3.0
48

59
## New Features

R/tidy_glmnet.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ get_glmn_coefs <- function(x, penalty = 0.01) {
4848
res <- tibble::as_tibble(res) %>% mutate(term = rn, penalty = penalty)
4949
res <- dplyr::select(res, term, estimate, penalty)
5050
if (is.list(res$estimate)) {
51-
res$estimate <- purrr::map(res$estimate, ~ as_tibble(as.matrix(.x), rownames = "term"))
51+
res$estimate <- purrr::map(
52+
res$estimate,
53+
~ as_tibble(as.matrix(.x), rownames = "term")
54+
)
5255
res <- tidyr::unnest(res, cols = c(estimate), names_repair = "minimal")
5356
names(res) <- c("class", "term", "estimate", "penalty")
5457
}
@@ -61,6 +64,6 @@ tidy_glmnet <- function(x, penalty = NULL, ..., call = caller_env()) {
6164
if (is.null(penalty)) {
6265
penalty <- x$spec$args$penalty
6366
}
64-
check_number_decimal(penalty, min = 0, max = 1, allow_null = TRUE, call = call)
67+
check_number_decimal(penalty, min = 0, allow_null = TRUE, call = call)
6568
get_glmn_coefs(x$fit, penalty = penalty)
6669
}

0 commit comments

Comments
 (0)