}}\preformatted{linear_reg() \%>\%
diff --git a/man/logistic_reg.Rd b/man/logistic_reg.Rd
index 6dff2100d..2859d9f9f 100644
--- a/man/logistic_reg.Rd
+++ b/man/logistic_reg.Rd
@@ -100,15 +100,38 @@ call. For this type of model, the template of the fit calls are below.
## family = "binomial")
}
-For \code{glmnet} models, the full regularization path is always fit
-regardless of the value given to \code{penalty}. Also, there is the option to
-pass multiple values (or no values) to the \code{penalty} argument. When
-using the \code{predict()} method in these cases, the return value depends on
-the value of \code{penalty}. When using \code{predict()}, only a single value of
-the penalty can be used. When predicting on multiple penalties, the
-\code{multi_predict()} function can be used. It returns a tibble with a list
-column called \code{.pred} that contains a tibble with all of the penalty
-results.
+The glmnet engine requires a single value for the \code{penalty} argument (a
+number or \code{tune()}), but the full regularization path is always fit
+regardless of the value given to \code{penalty}. To pass in a custom sequence
+of values for glmnet’s \code{lambda}, use the argument \code{path_values} in
+\code{set_engine()}. This will assign the value of the glmnet \code{lambda}
+parameter without disturbing the value given of \code{logistic_reg(penalty)}.
+For example:\if{html}{\out{
}}\preformatted{logistic_reg(penalty = .1) \%>\%
+ set_engine("glmnet", path_values = c(0, 10^seq(-10, 1, length.out = 20))) \%>\%
+ translate()
+}\if{html}{\out{
}}\preformatted{## Logistic Regression Model Specification (classification)
+##
+## Main Arguments:
+## penalty = 0.1
+##
+## Computational engine: glmnet
+##
+## Model fit template:
+## glmnet::glmnet(x = missing_arg(), y = missing_arg(), weights = missing_arg(),
+## lambda = c(0, 10^seq(-10, 1, length.out = 20)), family = "binomial")
+}
+
+When fitting a pure ridge regression model (i.e., \code{penalty = 0}), we
+\emph{strongly suggest} that you pass in a vector for \code{path_values} that
+includes zero. See \href{https://github.com/tidymodels/parsnip/issues/431}{issue #431} for a
+discussion.
+
+When using \code{predict()}, the single \code{penalty} value used for prediction
+is the one specified in \code{logistic_reg()}.
+
+To predict on multiple penalties, use the \code{multi_predict()} function.
+This function returns a tibble with a list column called \code{.pred}
+containing all of the penalty results.
}
\subsection{LiblineaR}{\if{html}{\out{
}}\preformatted{logistic_reg() \%>\%
diff --git a/man/multinom_reg.Rd b/man/multinom_reg.Rd
index 8dc8b2e5c..6d9ba5fcc 100644
--- a/man/multinom_reg.Rd
+++ b/man/multinom_reg.Rd
@@ -82,15 +82,38 @@ call. For this type of model, the template of the fit calls are below.
## family = "multinomial")
}
-For \code{glmnet} models, the full regularization path is always fit
-regardless of the value given to \code{penalty}. Also, there is the option to
-pass multiple values (or no values) to the \code{penalty} argument. When
-using the \code{predict()} method in these cases, the return value depends on
-the value of \code{penalty}. When using \code{predict()}, only a single value of
-the penalty can be used. When predicting on multiple penalties, the
-\code{multi_predict()} function can be used. It returns a tibble with a list
-column called \code{.pred} that contains a tibble with all of the penalty
-results.
+The glmnet engine requires a single value for the \code{penalty} argument (a
+number or \code{tune()}), but the full regularization path is always fit
+regardless of the value given to \code{penalty}. To pass in a custom sequence
+of values for glmnet’s \code{lambda}, use the argument \code{path_values} in
+\code{set_engine()}. This will assign the value of the glmnet \code{lambda}
+parameter without disturbing the value given of \code{multinom_reg(penalty)}.
+For example:\if{html}{\out{
}}\preformatted{multinom_reg(penalty = .1) \%>\%
+ set_engine("glmnet", path_values = c(0, 10^seq(-10, 1, length.out = 20))) \%>\%
+ translate()
+}\if{html}{\out{
}}\preformatted{## Multinomial Regression Model Specification (classification)
+##
+## Main Arguments:
+## penalty = 0.1
+##
+## Computational engine: glmnet
+##
+## Model fit template:
+## glmnet::glmnet(x = missing_arg(), y = missing_arg(), weights = missing_arg(),
+## lambda = c(0, 10^seq(-10, 1, length.out = 20)), family = "multinomial")
+}
+
+When fitting a pure ridge regression model (i.e., \code{penalty = 0}), we
+\emph{strongly suggest} that you pass in a vector for \code{path_values} that
+includes zero. See \href{https://github.com/tidymodels/parsnip/issues/431}{issue #431} for a
+discussion.
+
+When using \code{predict()}, the single \code{penalty} value used for prediction
+is the one specified in \code{multinom_reg()}.
+
+To predict on multiple penalties, use the \code{multi_predict()} function.
+This function returns a tibble with a list column called \code{.pred}
+containing all of the penalty results.
}
\subsection{nnet}{\if{html}{\out{
}}\preformatted{multinom_reg() \%>\%
diff --git a/man/rmd/linear-reg.Rmd b/man/rmd/linear-reg.Rmd
index 378f71db8..dbef43a45 100644
--- a/man/rmd/linear-reg.Rmd
+++ b/man/rmd/linear-reg.Rmd
@@ -21,14 +21,29 @@ linear_reg(penalty = 0.1) %>%
translate()
```
-For `glmnet` models, the full regularization path is always fit regardless of the
-value given to `penalty`. Also, there is the option to pass multiple values (or
-no values) to the `penalty` argument. When using the `predict()` method in these
-cases, the return value depends on the value of `penalty`. When using
-`predict()`, only a single value of the penalty can be used. When predicting on
-multiple penalties, the `multi_predict()` function can be used. It returns a
-tibble with a list column called `.pred` that contains a tibble with all of the
-penalty results.
+The glmnet engine requires a single value for the `penalty` argument (a number
+or `tune()`), but the full regularization path is always fit
+regardless of the value given to `penalty`. To pass in a custom sequence of
+values for glmnet's `lambda`, use the argument `path_values` in `set_engine()`.
+This will assign the value of the glmnet `lambda` parameter without disturbing
+the value given of `linear_reg(penalty)`. For example:
+
+```{r glmnet-path}
+linear_reg(penalty = .1) %>%
+ set_engine("glmnet", path_values = c(0, 10^seq(-10, 1, length.out = 20))) %>%
+ translate()
+```
+
+When fitting a pure ridge regression model (i.e., `penalty = 0`), we _strongly
+suggest_ that you pass in a vector for `path_values` that includes zero. See
+[issue #431](https://github.com/tidymodels/parsnip/issues/431) for a discussion.
+
+When using `predict()`, the single `penalty` value used for prediction is the
+one specified in `linear_reg()`.
+
+To predict on multiple penalties, use the `multi_predict()` function.
+This function returns a tibble with a list column called `.pred` containing
+all of the penalty results.
## stan
diff --git a/man/rmd/logistic-reg.Rmd b/man/rmd/logistic-reg.Rmd
index b28b44391..174183546 100644
--- a/man/rmd/logistic-reg.Rmd
+++ b/man/rmd/logistic-reg.Rmd
@@ -22,14 +22,30 @@ logistic_reg(penalty = 0.1) %>%
translate()
```
-For `glmnet` models, the full regularization path is always fit regardless of the
-value given to `penalty`. Also, there is the option to pass multiple values (or
-no values) to the `penalty` argument. When using the `predict()` method in these
-cases, the return value depends on the value of `penalty`. When using
-`predict()`, only a single value of the penalty can be used. When predicting on
-multiple penalties, the `multi_predict()` function can be used. It returns a
-tibble with a list column called `.pred` that contains a tibble with all of the
-penalty results.
+The glmnet engine requires a single value for the `penalty` argument (a number
+or `tune()`), but the full regularization path is always fit
+regardless of the value given to `penalty`. To pass in a custom sequence of
+values for glmnet's `lambda`, use the argument `path_values` in `set_engine()`.
+This will assign the value of the glmnet `lambda` parameter without disturbing
+the value given of `logistic_reg(penalty)`. For example:
+
+```{r glmnet-path}
+logistic_reg(penalty = .1) %>%
+ set_engine("glmnet", path_values = c(0, 10^seq(-10, 1, length.out = 20))) %>%
+ translate()
+```
+
+When fitting a pure ridge regression model (i.e., `penalty = 0`), we _strongly
+suggest_ that you pass in a vector for `path_values` that includes zero. See
+[issue #431](https://github.com/tidymodels/parsnip/issues/431) for a discussion.
+
+When using `predict()`, the single `penalty` value used for prediction is the
+one specified in `logistic_reg()`.
+
+To predict on multiple penalties, use the `multi_predict()` function.
+This function returns a tibble with a list column called `.pred` containing
+all of the penalty results.
+
## LiblineaR
diff --git a/man/rmd/multinom-reg.Rmd b/man/rmd/multinom-reg.Rmd
index 2071db327..878c1eb4c 100644
--- a/man/rmd/multinom-reg.Rmd
+++ b/man/rmd/multinom-reg.Rmd
@@ -14,14 +14,31 @@ multinom_reg(penalty = 0.1) %>%
translate()
```
-For `glmnet` models, the full regularization path is always fit regardless of the
-value given to `penalty`. Also, there is the option to pass multiple values (or
-no values) to the `penalty` argument. When using the `predict()` method in these
-cases, the return value depends on the value of `penalty`. When using
-`predict()`, only a single value of the penalty can be used. When predicting on
-multiple penalties, the `multi_predict()` function can be used. It returns a
-tibble with a list column called `.pred` that contains a tibble with all of the
-penalty results.
+The glmnet engine requires a single value for the `penalty` argument (a number
+or `tune()`), but the full regularization path is always fit
+regardless of the value given to `penalty`. To pass in a custom sequence of
+values for glmnet's `lambda`, use the argument `path_values` in `set_engine()`.
+This will assign the value of the glmnet `lambda` parameter without disturbing
+the value given of `multinom_reg(penalty)`. For example:
+
+
+```{r glmnet-path}
+multinom_reg(penalty = .1) %>%
+ set_engine("glmnet", path_values = c(0, 10^seq(-10, 1, length.out = 20))) %>%
+ translate()
+```
+
+When fitting a pure ridge regression model (i.e., `penalty = 0`), we _strongly
+suggest_ that you pass in a vector for `path_values` that includes zero. See
+[issue #431](https://github.com/tidymodels/parsnip/issues/431) for a discussion.
+
+When using `predict()`, the single `penalty` value used for prediction is the
+one specified in `multinom_reg()`.
+
+To predict on multiple penalties, use the `multi_predict()` function.
+This function returns a tibble with a list column called `.pred` containing
+all of the penalty results.
+
## nnet
diff --git a/tests/testthat/test_linear_reg.R b/tests/testthat/test_linear_reg.R
index b839572e8..efcf0138c 100644
--- a/tests/testthat/test_linear_reg.R
+++ b/tests/testthat/test_linear_reg.R
@@ -142,6 +142,19 @@ test_that('engine arguments', {
)
)
+ # For issue #431
+ with_path <-
+ linear_reg(penalty = 1) %>%
+ set_engine("glmnet", path_values = 4:2) %>%
+ translate()
+ expect_equal(
+ names(with_path$method$fit$args),
+ c("x", "y", "weights", "lambda", "family")
+ )
+ expect_equal(
+ rlang::eval_tidy(with_path$method$fit$args$lambda),
+ 4:2
+ )
})
diff --git a/tests/testthat/test_logistic_reg.R b/tests/testthat/test_logistic_reg.R
index 5b2c9df1b..25cbcccd8 100644
--- a/tests/testthat/test_logistic_reg.R
+++ b/tests/testthat/test_logistic_reg.R
@@ -130,7 +130,7 @@ test_that('primary arguments', {
)
)
- penalty_v <- logistic_reg(penalty = varying())
+ penalty_v <- logistic_reg(penalty = 1)
penalty_v_glmnet <- translate(penalty_v %>% set_engine("glmnet"))
penalty_v_liblinear <- translate(penalty_v %>% set_engine("LiblineaR"))
penalty_v_spark <- translate(penalty_v %>% set_engine("spark"))
@@ -147,7 +147,7 @@ test_that('primary arguments', {
x = expr(missing_arg()),
y = expr(missing_arg()),
wi = expr(missing_arg()),
- cost = new_empty_quosure(varying()),
+ cost = new_empty_quosure(1),
verbose = FALSE
)
)
@@ -156,7 +156,7 @@ test_that('primary arguments', {
x = expr(missing_arg()),
formula = expr(missing_arg()),
weight_col = expr(missing_arg()),
- reg_param = new_empty_quosure(varying()),
+ reg_param = new_empty_quosure(1),
family = "binomial"
)
)
@@ -228,6 +228,19 @@ test_that('engine arguments', {
)
)
+ # For issue #431
+ with_path <-
+ logistic_reg(penalty = 1) %>%
+ set_engine("glmnet", path_values = 4:2) %>%
+ translate()
+ expect_equal(
+ names(with_path$method$fit$args),
+ c("x", "y", "weights", "lambda", "family")
+ )
+ expect_equal(
+ rlang::eval_tidy(with_path$method$fit$args$lambda),
+ 4:2
+ )
})
diff --git a/tests/testthat/test_multinom_reg.R b/tests/testthat/test_multinom_reg.R
index 6a1b0037d..6687d0e60 100644
--- a/tests/testthat/test_multinom_reg.R
+++ b/tests/testthat/test_multinom_reg.R
@@ -67,6 +67,19 @@ test_that('engine arguments', {
)
)
+ # For issue #431
+ with_path <-
+ multinom_reg(penalty = 1) %>%
+ set_engine("glmnet", path_values = 4:2) %>%
+ translate()
+ expect_equal(
+ names(with_path$method$fit$args),
+ c("x", "y", "weights", "lambda", "family")
+ )
+ expect_equal(
+ rlang::eval_tidy(with_path$method$fit$args$lambda),
+ 4:2
+ )
})