当我们通过 parsnip 和 recipe 包调用它们时,space-填充参数网格如何变化?

How do space-filling parameter grids change when we call them by parsnip and recipe packages?

根据此 (https://dials.tidymodels.org/reference/grid_max_entropy.html) 页面,网格函数的输出可能会有所不同,具体取决于我们是否使用由 parsniprecipes 生成的参数对象,或者我们直接使用参数对象。但是,不清楚 如果我们使用从模型或配方创建的 parameters 对象,如何获取参数范围。例如,neighbors() 的默认范围是 [1, 10]。当我使用

myGrid <- grid_latin_hypercube(extract_parameter_set_dials(x), size = 25)

其中x为模型,使用

获取范围
range(myGrid$neighbors)

我的 neighbors 得到了一些超出 [1,10] 的值。当我使用从模型或配方创建的 parameters 对象时,如何获得 neighbors 的默认范围?

如您在文档中所见:

the parsnip and recipe packages may override the default ranges for specific models and preprocessing steps. If the grid function uses a parameters object created from a model or recipe, the ranges may have different defaults (specific to those models)

您可以通过查看参数集对象的 object 元素来查看范围。

library(tidymodels)

knn_spec <- nearest_neighbor(neighbors = tune())

extract_parameter_set_dials(knn_spec)$object
#> [[1]]
#> # Nearest Neighbors (quantitative)
#> Range: [1, 15]

reprex package (v2.0.1)

于 2022-05-13 创建