在 tidymodels 中,发送到 `recipe` 的数据与发送到 `resample` 函数的数据有何关系?

问题描述 投票:0回答:1
在这个带有交叉验证的正则化回归的

workflow

 中,提供了两次数据:在 
recipe
 调用和 
vfold_cv
 调用中。

如果

recipe

 对数据执行一些预处理而 
vfold_cv
 函数不执行,这不会导致冲突吗?似乎 
recipe
 可以安排和扩展虚拟对象等,从而改变观察的顺序和数据框中列的数据类型。

library(tidymodels) model <- workflow() |> add_recipe( recipe(mpg ~ wt + cyl + drat + qsec + vs + am, data = mtcars) |> # here step_scale() |> step_center() ) |> add_model( linear_reg(penalty = tune()) |> set_engine("glmnet") ) |> tune_grid( resamples = vfold_cv(v = 5, data = mtcars), # and here #grid = 30 # doesn't capture the minimum rmse grid = tibble(penalty = 10^seq(-8, 1, length.out = 40)) ) #> Warning: package 'glmnet' was built under R version 4.3.3 #> → A | warning: A correlation computation is required, but `estimate` is constant and has 0 #> standard deviation, resulting in a divide by 0 error. `NA` will be returned. #> There were issues with some computations A: x1There were issues with some computations A: x2There were issues with some computations A: x4There were issues with some computations A: x5 model |> autoplot()

创建于 2024-04-15,使用 reprex v2.0.2

r tidymodels
1个回答
0
投票
食谱在幕后处理这个问题

https://forum.posit.co/t/is-there-a-need-to-prep-a-recipe-when-using-vfold-cv-workflow-fit-resample-and-last-fit/ 77875/2

© www.soinside.com 2019 - 2024. All rights reserved.