Skip to content

Commit d7133ec

Browse files
committed
rename glmnet helpers for clarity
`check_glmnet_penalty()` --> `check_glmnet_penalty_fit()` `check_penalty()` --> `check_glmnet_penalty_predict()`
1 parent db16e3e commit d7133ec

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

NAMESPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ export(augment)
122122
export(boost_tree)
123123
export(check_empty_ellipse)
124124
export(check_final_param)
125-
export(check_glmnet_penalty)
126-
export(check_penalty)
125+
export(check_glmnet_penalty_fit)
126+
export(check_glmnet_penalty_predict)
127127
export(contr_one_hot)
128128
export(control_parsnip)
129129
export(convert_stan_interval)

R/linear_reg.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ translate.linear_reg <- function(x, engine = x$engine, ...) {
107107
x <- translate.default(x, engine, ...)
108108

109109
if (engine == "glmnet") {
110-
check_glmnet_penalty(x)
110+
check_glmnet_penalty_fit(x)
111111
if (any(names(x$eng_args) == "path_values")) {
112112
# Since we decouple the parsnip `penalty` argument from being the same
113113
# as the glmnet `lambda` value, `path_values` allows users to set the
@@ -244,7 +244,7 @@ predict._elnet <-
244244
penalty <- object$spec$args$penalty
245245
}
246246

247-
object$spec$args$penalty <- check_penalty(penalty, object, multi)
247+
object$spec$args$penalty <- check_glmnet_penalty_predict(penalty, object, multi)
248248

249249
object$spec <- eval_args(object$spec)
250250
predict.model_fit(object, new_data = new_data, type = type, opts = opts, ...)

R/logistic_reg.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ translate.logistic_reg <- function(x, engine = x$engine, ...) {
109109
arg_names <- names(arg_vals)
110110

111111
if (engine == "glmnet") {
112-
check_glmnet_penalty(x)
112+
check_glmnet_penalty_fit(x)
113113
if (any(names(x$eng_args) == "path_values")) {
114114
# Since we decouple the parsnip `penalty` argument from being the same
115115
# as the glmnet `lambda` value, `path_values` allows users to set the
@@ -296,7 +296,7 @@ predict._lognet <- function(object, new_data, type = NULL, opts = list(), penalt
296296
penalty <- object$spec$args$penalty
297297
}
298298

299-
object$spec$args$penalty <- check_penalty(penalty, object, multi)
299+
object$spec$args$penalty <- check_glmnet_penalty_predict(penalty, object, multi)
300300

301301
object$spec <- eval_args(object$spec)
302302
predict.model_fit(object, new_data = new_data, type = type, opts = opts, ...)

R/misc.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,18 @@ stan_conf_int <- function(object, newdata) {
329329
#' Helper functions for checking the penalty of glmnet models
330330
#'
331331
#' @description
332-
#' `check_glmnet_penalty()` checks that the model specification for fitting a
332+
#' `check_glmnet_penalty_fit()` checks that the model specification for fitting a
333333
#' glmnet model contains a single value.
334334
#'
335-
#' `check_penalty()` checks that the penalty value used for prediction is valid.
335+
#' `check_glmnet_penalty_predict()` checks that the penalty value used for prediction is valid.
336336
#' If called by `predict()`, it needs to be a single value. Multiple values are
337337
#' allowed for `multi_predict()`.
338338
#'
339339
#' @param x An object of class `model_spec`.
340340
#' @rdname glmnet_helpers
341341
#' @keywords internal
342342
#' @export
343-
check_glmnet_penalty <- function(x) {
343+
check_glmnet_penalty_fit <- function(x) {
344344
pen <- rlang::eval_tidy(x$args$penalty)
345345

346346
if (length(pen) != 1) {
@@ -360,7 +360,7 @@ check_glmnet_penalty <- function(x) {
360360
#' @rdname glmnet_helpers
361361
#' @keywords internal
362362
#' @export
363-
check_penalty <- function(penalty = NULL, object, multi = FALSE) {
363+
check_glmnet_penalty_predict <- function(penalty = NULL, object, multi = FALSE) {
364364

365365
if (is.null(penalty)) {
366366
penalty <- object$fit$lambda

R/multinom_reg.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ predict._multnet <-
222222
penalty <- object$spec$args$penalty
223223
}
224224

225-
object$spec$args$penalty <- check_penalty(penalty, object, multi)
225+
object$spec$args$penalty <- check_glmnet_penalty_predict(penalty, object, multi)
226226

227227
object$spec <- eval_args(object$spec)
228228
res <- predict.model_fit(

man/glmnet_helpers.Rd

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)