22# '
33# ' `linear_reg` is a way to generate a _specification_ of a model
44# ' before fitting and allows the model to be created using
5- # ' different packages in R, Stan, or via Spark. The main arguments for the
6- # ' model are:
5+ # ' different packages in R, Stan, keras, or via Spark. The main
6+ # ' arguments for the model are:
77# ' \itemize{
88# ' \item \code{penalty}: The total amount of regularization
9- # ' in the model. Note that this must be zero for some engines .
9+ # ' in the model. Note that this must be zero for some engines.
1010# ' \item \code{mixture}: The proportion of L1 regularization in
1111# ' the model. Note that this will be ignored for some engines.
1212# ' }
1919# ' @inheritParams boost_tree
2020# ' @param mode A single character string for the type of model.
2121# ' The only possible value for this model is "regression".
22- # ' @param penalty An non-negative number representing the
23- # ' total amount of regularization (`glmnet` and `spark` only).
22+ # ' @param penalty An non-negative number representing the total
23+ # ' amount of regularization (`glmnet`, `keras`, and `spark` only).
24+ # ' For `keras` models, this corresponds to purely L2 regularization
25+ # ' (aka weight decay) while the other models can be a combination
26+ # ' of L1 and L2 (depending on the value of `mixture`).
2427# ' @param mixture A number between zero and one (inclusive) that
2528# ' represents the proportion of regularization that is used for the
2629# ' L2 penalty (i.e. weight decay, or ridge regression) versus L1
3639# ' \item \pkg{R}: `"lm"` or `"glmnet"`
3740# ' \item \pkg{Stan}: `"stan"`
3841# ' \item \pkg{Spark}: `"spark"`
42+ # ' \item \pkg{keras}: `"keras"`
3943# ' }
4044# '
4145# ' @section Engine Details:
5963# ' \pkg{spark}
6064# '
6165# ' \Sexpr[results=rd]{parsnip:::show_fit(parsnip:::linear_reg(), "spark")}
66+ # '
67+ # ' \pkg{keras}
68+ # '
69+ # ' \Sexpr[results=rd]{parsnip:::show_fit(parsnip:::linear_reg(), "keras")}
6270# '
6371# ' When using `glmnet` models, there is the option to pass
6472# ' multiple values (or no values) to the `penalty` argument.
@@ -211,18 +219,27 @@ organize_glmnet_pred <- function(x, object) {
211219# ' @export
212220predict._elnet <-
213221 function (object , new_data , type = NULL , opts = list (), ... ) {
222+ if (any(names(enquos(... )) == " newdata" ))
223+ stop(" Did you mean to use `new_data` instead of `newdata`?" , call. = FALSE )
224+
214225 object $ spec <- eval_args(object $ spec )
215226 predict.model_fit(object , new_data = new_data , type = type , opts = opts , ... )
216227 }
217228
218229# ' @export
219- predict_num._elnet <- function (object , new_data , ... ) {
230+ predict_numeric._elnet <- function (object , new_data , ... ) {
231+ if (any(names(enquos(... )) == " newdata" ))
232+ stop(" Did you mean to use `new_data` instead of `newdata`?" , call. = FALSE )
233+
220234 object $ spec <- eval_args(object $ spec )
221- predict_num .model_fit(object , new_data = new_data , ... )
235+ predict_numeric .model_fit(object , new_data = new_data , ... )
222236}
223237
224238# ' @export
225239predict_raw._elnet <- function (object , new_data , opts = list (), ... ) {
240+ if (any(names(enquos(... )) == " newdata" ))
241+ stop(" Did you mean to use `new_data` instead of `newdata`?" , call. = FALSE )
242+
226243 object $ spec <- eval_args(object $ spec )
227244 predict_raw.model_fit(object , new_data = new_data , opts = opts , ... )
228245}
@@ -232,6 +249,9 @@ predict_raw._elnet <- function(object, new_data, opts = list(), ...) {
232249# ' @export
233250multi_predict._elnet <-
234251 function (object , new_data , type = NULL , penalty = NULL , ... ) {
252+ if (any(names(enquos(... )) == " newdata" ))
253+ stop(" Did you mean to use `new_data` instead of `newdata`?" , call. = FALSE )
254+
235255 dots <- list (... )
236256 if (is.null(penalty ))
237257 penalty <- object $ fit $ lambda
0 commit comments