curso-r / treesnip

Parsnip backends for `tree`, `lightGBM` and `Catboost`
https://curso-r.github.io/treesnip
GNU General Public License v3.0
86 stars 13 forks source link

ancillary objects and S3 methods for models #31

Open topepo opened 3 years ago

topepo commented 3 years ago

As I'm writing the party package methods for #30, I thought that it might be helpful to list some other connections to make to other tidymodels packages

Parameter objects

If you have any tuning parameters that need dials objects, we could take a dials dependency and add them here or add a PR to dials. I would only add them to dials if you think that there are other models/packages that would be able to use them. For my PR, I'll keep them in treesnip since they are specific to conditional inference trees.

Tuning related things

There are also two other components that probably need some specification to work better with tune.

First, if there are tuning parameters that can use multi_predict(), you will want to set up an S3 min_grid() method. This basically tells tune how to use the submodes efficiently. tune exports a function called fit_max_value() that makes this pretty easy.

Second, if there are parameters that people will want to tune but are not main arguments, you can better enable that to happen by listing them as tunable parameters with the S3 method tunable. Basically it just lists their argument names and the corresponding dials object that should be used. This is described in details on tidymodels.org.

For example, for the randomForest engine, people might want to tune over maxnodes. tune contains this tibble to set that up:

> tune:::randomForest_engine_args
# A tibble: 1 x 5
  name     call_info        source     component   component_id
  <chr>    <list>           <chr>      <chr>       <chr>       
1 maxnodes <named list [2]> model_spec rand_forest engine      
> tune:::randomForest_engine_args$call_info
[[1]]
[[1]]$pkg
[1] "dials"

[[1]]$fun
[1] "max_nodes"

For both of these tune-related items, they need underlying functions in tune so it would be better to PR into tune for them. I'll set that up in a PR for the party models and link to this issue to help make it easier.