grid_random function errors out: 'object' should be a 'quant_param' object

0

I am going through a blog post on tidymodels (random forest regression) and for some reason, I keep getting Error: object should be a 'quant_param' object when I run the code chunk below

grid_tidym <- grid_random(
  mtry %>% range_set(c( 1,  14)),
  trees %>% range_set(c( 500, 1000)), 
  min_n %>% range_set(c(2,  10)),
  size = 30
)

How do I get out of this? Thanks.

Hi, this is an application of the lazy evaluation principle that you should keep in mind: the reproducible example, called a reprex .

In this case, what is grid_random()?

As of a version or two ago, dials changed its parameter objects to be functions instead of pre-compiled objects.

library(dials)
#> Loading required package: scales
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

grid_random(
  mtry() %>% range_set(c( 1,  14)),
  trees() %>% range_set(c( 500, 1000)), 
  min_n() %>% range_set(c(2,  10)),
  size = 30
)
#> # A tibble: 30 x 3
#>     mtry trees min_n
#>    <int> <int> <int>
#>  1     1   727     4
#>  2    10   589     7
#>  3     7   538     2
#>  4     1   710     9
#>  5     4   703     4
#>  6     5   917     2
#>  7     8   672     7
#>  8     1   886     5
#>  9    14   725     5
#> 10    13   851    10
#> # ā€¦ with 20 more rows

Created on 2020-01-18 by the reprex package (v0.3.0)

1 Like

Just what I needed. Thanks very much, Max.

1 Like

Great. Please mark the solution for the benefit of those to follow.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.