File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,23 @@ print.linear_reg <- function(x, ...) {
138138 invisible (x )
139139}
140140
141+
142+ # ' @export
143+ translate.linear_reg <- function (x , engine = x $ engine , ... ) {
144+ x <- translate.default(x , engine , ... )
145+
146+ if (engine == " glmnet" ) {
147+ # See discussion in https://github.com/tidymodels/parsnip/issues/195
148+ x $ method $ fit $ args $ lambda <- NULL
149+ # Since the `fit` infomration is gone for the penalty, we need to have an
150+ # evaludated value for the parameter.
151+ x $ args $ penalty <- rlang :: eval_tidy(x $ args $ penalty )
152+ }
153+
154+ x
155+ }
156+
157+
141158# ------------------------------------------------------------------------------
142159
143160# ' @inheritParams update.boost_tree
@@ -274,6 +291,11 @@ predict._elnet <-
274291 if (any(names(enquos(... )) == " newdata" ))
275292 stop(" Did you mean to use `new_data` instead of `newdata`?" , call. = FALSE )
276293
294+ # See discussion in https://github.com/tidymodels/parsnip/issues/195
295+ if (is.null(penalty ) & ! is.null(object $ spec $ args $ penalty )) {
296+ penalty <- object $ spec $ args $ penalty
297+ }
298+
277299 object $ spec $ args $ penalty <- check_penalty(penalty , object , multi )
278300
279301 object $ spec <- eval_args(object $ spec )
You can’t perform that action at this time.
0 commit comments