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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: parsnip
Title: A Common API to Modeling and Analysis Functions
Version: 1.0.3.9000
Version: 1.0.3.9001
Authors@R: c(
person("Max", "Kuhn", , "max@rstudio.com", role = c("aut", "cre")),
person("Davis", "Vaughan", , "davis@rstudio.com", role = "aut"),
Expand Down
7 changes: 4 additions & 3 deletions R/logistic_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@ multi_predict._lognet <-
}
}

dots$s <- penalty

if (is.null(type))
type <- "class"
if (!(type %in% c("class", "prob", "link", "raw"))) {
Expand All @@ -284,7 +282,9 @@ multi_predict._lognet <-
dots$type <- type

object$spec <- eval_args(object$spec)
pred <- predict.model_fit(object, new_data = new_data, type = "raw", opts = dots)
pred <- predict._lognet(object, new_data = new_data, type = "raw",
opts = dots, penalty = penalty, multi = TRUE)

param_key <- tibble(group = colnames(pred), penalty = penalty)
pred <- as_tibble(pred)
pred$.row <- 1:nrow(pred)
Expand Down Expand Up @@ -340,6 +340,7 @@ predict_raw._lognet <- function(object, new_data, opts = list(), ...) {
rlang::abort("Did you mean to use `new_data` instead of `newdata`?")

object$spec <- eval_args(object$spec)
opts$s <- object$spec$args$penalty
predict_raw.model_fit(object, new_data = new_data, opts = opts, ...)
}

Expand Down
6 changes: 4 additions & 2 deletions R/multinom_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ multi_predict._multnet <-
penalty <- eval_tidy(penalty)

dots <- list(...)

if (is.null(penalty)) {
# See discussion in https://github.com/tidymodels/parsnip/issues/195
if (!is.null(object$spec$args$penalty)) {
Expand All @@ -208,7 +209,6 @@ multi_predict._multnet <-
penalty <- object$fit$lambda
}
}
dots$s <- penalty

if (is.null(type))
type <- "class"
Expand All @@ -221,7 +221,8 @@ multi_predict._multnet <-
dots$type <- type

object$spec <- eval_args(object$spec)
pred <- predict.model_fit(object, new_data = new_data, type = "raw", opts = dots)
pred <- predict._multnet(object, new_data = new_data, type = "raw",
opts = dots, penalty = penalty, multi = TRUE)

format_probs <- function(x) {
x <- as_tibble(x)
Expand Down Expand Up @@ -268,5 +269,6 @@ predict_classprob._multnet <- function(object, new_data, ...) {
#' @export
predict_raw._multnet <- function(object, new_data, opts = list(), ...) {
object$spec <- eval_args(object$spec)
opts$s <- object$spec$args$penalty
predict_raw.model_fit(object, new_data = new_data, opts = opts, ...)
}