Skip to content

tuning a model with a single glmnet penalty value #1119

@topepo

Description

@topepo
library(tidymodels)

set.seed(1)
rs <- vfold_cv(two_class_dat)
# error 1: At least one penalty value is required for glmnet.

thresh_tlr <- tailor() |> adjust_probability_threshold(threshold = tune())

glmn_spec <- 
  logistic_reg(penalty = 0.01) |> 
  set_engine("glmnet")

glmn_wflow <- workflow(Class ~ ., glmn_spec, thresh_tlr)

set.seed(2)
res <- 
  glmn_wflow |> 
  tune_grid(resamples = rs)
#> Error in `dplyr::mutate()`:
#> ℹ In argument: `model_stage = purrr::map(...)`.
#> Caused by error in `purrr::map()`:
#> ℹ In index: 1.
#> Caused by error in `no_penalty()`:
#> ! At least one penalty value is required for glmnet.
# This does not help

glmn_spec <- 
  logistic_reg(penalty = 0.01) |> 
  set_engine("glmnet", path_values = 10^seq(-4:0))

glmn_wflow <- workflow(Class ~ ., glmn_spec, thresh_tlr)

set.seed(2)
res <- 
  glmn_wflow |> 
  tune_grid(resamples = rs)
#> Error in `dplyr::mutate()`:
#> ℹ In argument: `model_stage = purrr::map(...)`.
#> Caused by error in `purrr::map()`:
#> ℹ In index: 1.
#> Caused by error in `no_penalty()`:
#> ! At least one penalty value is required for glmnet.

Created on 2026-01-12 with reprex v2.1.1

This appears to be a min_grid() issue. Even though the penalty is not tuned, it is checking to see if there is a penalty column in the grid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions