【问题标题】:Tune parameters not detected with tidymodels使用 tidymodels 未检测到调整参数
【发布时间】:2020-11-15 10:20:01
【问题描述】:

在上次更新之前,以下代码有效:

model_recipe_prep <- recipe( leads_dda ~ ., data = train_data) %>%
  step_rm(dt,cost) %>% 
  step_normalize( all_numeric(), -all_outcomes() ) %>% 
  step_BoxCox( all_numeric(), -all_outcomes(), -starts_with("number_")) %>%
  step_dummy( all_nominal(), one_hot = TRUE) %>% 
  step_poly(impressions, degree = tune() ) %>% 
  step_nzv(all_predictors() ) 

# ---- Metrics ----
model_control_metrics <- metric_set( rmse, mae, rsq )
model_control         <- control_grid(save_pred = TRUE)

model_baseline <- linear_reg() %>% 
  set_engine("lm") %>% 
  set_mode("regression")

set.seed(3456)
model_baseline_recipe_grid  <- expand.grid(degree = 1:3)
#model_baseline_engine_grid <- grid_regular()
#model_baseline_grid        <- merge(model_recipe_base_linear, model_baseline_engine_grid)

model_baseline_tune <- tune_grid(
  model_baseline,
  model_recipe_prep,
  resamples = train_data_kfolds,
  grid = model_baseline_recipe_grid,
  control = model_control,
  metrics = model_control_metrics
)

但现在我开始收到如下错误:

警告消息:1:未检测到调整参数, 性能将使用没有调整的重采样进行评估。做过 你想要 [fit_resamples()]? 2:所有模型在 tune_grid() 中均失败。看 .notes 列。

在 .notes 字段中,我有类似的内容:

"recipe: 错误:您不能 prep() 可调配方。参数 与tune(): '度'。您是否要使用调整功能,例如 tune_grid()?

也许我错过了一些非常愚蠢的东西,但我不知道如何让它再次工作。

另外,如果我检查一下

tune_args(model_recipe_prep)

因为 model_recipe_prep 没有可靠的参数,所以我有一个空的 nibble。

【问题讨论】:

    标签: r tidyverse tidymodels


    【解决方案1】:

    不幸的是,我们了解到,在某些情况下,刚刚进入 CRAN 的新版本配方与 CRAN 上的当前调整版本之间可能存在不匹配。我们正在尽快发布调整版本,但与此同时,如果您能够通过devtools::install_github("tidymodels/tune") 从 GitHub 进行安装,这应该可以解决您的问题,并且您应该会看到如下内容:

    library(tidymodels)
    
    rec1 <- recipe( mpg ~ ., data = mtcars) %>%
        step_normalize( all_numeric(), -all_outcomes() ) %>% 
        step_BoxCox( all_numeric(), -all_outcomes(), -starts_with("number_")) %>%
        step_dummy( all_nominal(), one_hot = TRUE) %>% 
        step_poly(disp, degree = tune() ) %>% 
        step_nzv(all_predictors() ) 
    
    tunable(rec1)
    #> # A tibble: 3 x 5
    #>   name       call_info        source component component_id
    #>   <chr>      <list>           <chr>  <chr>     <chr>       
    #> 1 degree     <named list [2]> recipe step_poly poly_Dj0QK  
    #> 2 freq_cut   <named list [2]> recipe step_nzv  nzv_zIzsm   
    #> 3 unique_cut <named list [2]> recipe step_nzv  nzv_zIzsm
    tune_args(rec1)
    #> # A tibble: 1 x 6
    #>   name   tunable id     source component component_id
    #>   <chr>  <lgl>   <chr>  <chr>  <chr>     <chr>       
    #> 1 degree TRUE    degree recipe step_poly poly_Dj0QK
    

    reprex package (v0.3.0.9001) 于 2020 年 11 月 15 日创建

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-31
      • 2021-06-12
      • 2021-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-09
      相关资源
      最近更新 更多