r - 使用 tidymodels 未检测到调整参数
问题描述
直到最后更新以下代码有效:
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 字段中,我有类似的内容:
“配方:错误:您无法
prep()
调整配方。参数带有tune()
:'degree'。您想使用调整功能吗?例如tune_grid()
?
也许我错过了一些非常愚蠢的东西,但我不知道如何让它再次工作。
另外,如果我检查
tune_args(model_recipe_prep)
因为 model_recipe_prep 没有可靠的参数,所以我有一个空的半字节。
解决方案
不幸的是,我们了解到,在某些情况下,刚刚进入 CRAN 的新版本食谱与 CRAN 上的当前调整版本之间可能存在不匹配。我们正在尽快发布调整版本,但与此同时,如果您能够通过 GitHub 进行安装devtools::install_github("tidymodels/tune")
,应该可以解决您的问题,您应该会看到如下内容:
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 包(v0.3.0.9001)于 2020 年 11 月 15 日创建
推荐阅读
- c# - 如何强制 NetworkStream 使用 SSL?
- android - 如何在Recyclerview android中更改特定行的textview的可见性
- django - 如何使用 geojson 从 django 正确获取坐标到传单
- php - 如何编辑此代码以使其仅影响我的 wordpress 网站上的顶部菜单而不影响主菜单?
- python - 您可以使用 Python 将文件移动到 gcloud VM 实例吗
- tooltip - 散景工具提示不显示
- c - 在作为值传递的结构地址上设置 NULL
- python - 文件夹中的图像文件按字母顺序排序。但是附加列表不是按这个顺序
- java - 在Java中创建对象的ID
- flutter - Dart 中的字符串文字类型模拟