没有适用于 'extract_parameter_set_dials' 的方法应用于 class "workflow" 的对象
no applicable method for 'extract_parameter_set_dials' applied to an object of class "workflow"
继优秀书籍 Tidy modeling with R、Section 14.1 之后,作者介绍了 SVM 模型超参数调整的案例:
library(tidymodels)
tidymodels_prefer()
data(cells, package = "modeldata")
cells <- cells[, -1] # remove case column
svm_rec <-
recipe(class ~ ., data = cells) %>%
step_YeoJohnson(all_numeric_predictors()) %>%
step_normalize(all_numeric_predictors())
svm_spec <-
svm_rbf(cost = tune(), rbf_sigma = tune()) %>%
set_engine("kernlab") %>%
set_mode("classification")
svm_wflow <-
workflow() %>%
add_model(svm_spec) %>%
add_recipe(svm_rec)
之后,他们说明了如何更改内核参数范围,以改进搜索的可视化:
svm_param <-
svm_wflow %>%
extract_parameter_set_dials() %>%
update(rbf_sigma = rbf_sigma(c(-7, -1)))
但这会导致错误:
Error in UseMethod("extract_parameter_set_dials") :
no applicable method for 'extract_parameter_set_dials' applied to an object of class "workflow"
这是因为 tidymodels 框架的更新吗?提取和修改超参数范围的正确方法是什么?
tidymodels packages recently had releases of dials 和添加此新通用的其他包(如工作流):
library(tidymodels)
tidymodels_prefer()
data(cells, package = "modeldata")
cells <- cells[, -1] # minus case
svm_rec <- recipe(class ~ ., data = cells) |>
step_YeoJohnson(all_numeric_predictors()) |>
step_normalize(all_numeric_predictors())
svm_spec <- svm_rbf(cost = tune(), rbf_sigma = tune()) |>
set_engine("kernlab") |>
set_mode("classification")
svm_wflow <- workflow() |>
add_model(svm_spec) |>
add_recipe(svm_rec)
svm_wflow |>
extract_parameter_set_dials() |>
update(rbf_sigma = rbf_sigma(c(-7, -1)))
#> Collection of 2 parameters for tuning
#>
#> identifier type object
#> cost cost nparam[+]
#> rbf_sigma rbf_sigma nparam[+]
由 reprex package (v2.0.1)
于 2022-04-02 创建
您可以 read more here,我们建议您从 CRAN 更新您的软件包。
继优秀书籍 Tidy modeling with R、Section 14.1 之后,作者介绍了 SVM 模型超参数调整的案例:
library(tidymodels)
tidymodels_prefer()
data(cells, package = "modeldata")
cells <- cells[, -1] # remove case column
svm_rec <-
recipe(class ~ ., data = cells) %>%
step_YeoJohnson(all_numeric_predictors()) %>%
step_normalize(all_numeric_predictors())
svm_spec <-
svm_rbf(cost = tune(), rbf_sigma = tune()) %>%
set_engine("kernlab") %>%
set_mode("classification")
svm_wflow <-
workflow() %>%
add_model(svm_spec) %>%
add_recipe(svm_rec)
之后,他们说明了如何更改内核参数范围,以改进搜索的可视化:
svm_param <-
svm_wflow %>%
extract_parameter_set_dials() %>%
update(rbf_sigma = rbf_sigma(c(-7, -1)))
但这会导致错误:
Error in UseMethod("extract_parameter_set_dials") :
no applicable method for 'extract_parameter_set_dials' applied to an object of class "workflow"
这是因为 tidymodels 框架的更新吗?提取和修改超参数范围的正确方法是什么?
tidymodels packages recently had releases of dials 和添加此新通用的其他包(如工作流):
library(tidymodels)
tidymodels_prefer()
data(cells, package = "modeldata")
cells <- cells[, -1] # minus case
svm_rec <- recipe(class ~ ., data = cells) |>
step_YeoJohnson(all_numeric_predictors()) |>
step_normalize(all_numeric_predictors())
svm_spec <- svm_rbf(cost = tune(), rbf_sigma = tune()) |>
set_engine("kernlab") |>
set_mode("classification")
svm_wflow <- workflow() |>
add_model(svm_spec) |>
add_recipe(svm_rec)
svm_wflow |>
extract_parameter_set_dials() |>
update(rbf_sigma = rbf_sigma(c(-7, -1)))
#> Collection of 2 parameters for tuning
#>
#> identifier type object
#> cost cost nparam[+]
#> rbf_sigma rbf_sigma nparam[+]
由 reprex package (v2.0.1)
于 2022-04-02 创建您可以 read more here,我们建议您从 CRAN 更新您的软件包。