Skip to content

Document default ranges for tuning parameters #954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
emmafeuer opened this issue Mar 31, 2023 · 3 comments · Fixed by #1150
Closed

Document default ranges for tuning parameters #954

emmafeuer opened this issue Mar 31, 2023 · 3 comments · Fixed by #1150
Labels
documentation tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@emmafeuer
Copy link

when you run the neighbors() in R, it returns that the default range is [1,10]. Additionally, when you look up the documentation for neighbors(), it says the default is [1,10].

However, when you set neighbors = tune() in a model and try to use the default range, R selects a range of [1, 15] instead of [1, 10]. This can be seen when you run extract_set_parameter_dials() and look at the range.

it would be super helpful to have this discrepancy fixed, either by changing the documentation to be [1, 15] or changing the default that results when you set neighbors = tune()
Screenshot 2023-03-31 at 1 47 42 PM
Screenshot 2023-03-31 at 1 48 03 PM

@EmilHvitfeldt
Copy link
Member

Hello @emmafeuer 👋 Thanks for submitting this issue!

What is happening here is the difference between the default dials objects and the model specific dials objects.

You are correct that it has the range 1-10.

library(tidymodels)

neighbors()
#> # Nearest Neighbors (quantitative)
#> Range: [1, 10]

grid_regular(neighbors())
#> # A tibble: 3 × 1
#>   neighbors
#>       <int>
#> 1         1
#> 2         5
#> 3        10

So you could pass dials::parameters(neighbors()) to the param_info argument of tune_grid() and it would use the range [1, 10]` to create the grid.

when you call extract_parameter_set_dials() you extract a parameters object from the model specification. These contain dials objects, but they are allowed to have different defaults the the plain dials objects.

func = list(pkg = "dials", fun = "neighbors", range = c(1, 15)),

this is admittedly not documented super well on parsnips side. So if you don't pass anything to param_info or grid in tune_grid() then it will use the model-specific ranges

knn_mod <- nearest_neighbor(neighbors = tune()) |>
  set_mode("classification") |>
  set_engine("kknn")

knn_param_set <- extract_parameter_set_dials(knn_mod) 

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

grid_regular(knn_param_set)
#> # A tibble: 3 × 1
#>   neighbors
#>       <int>
#> 1         1
#> 2         8
#> 3        15

Created on 2023-03-31 with reprex v2.0.2

@hfrick hfrick changed the title documentation error of neighbors() Document default ranges for tuning parameters Apr 27, 2023
@hfrick
Copy link
Member

hfrick commented Apr 27, 2023

I'm going to move this to parsnip because this is about documenting the default ranges used by parsnip models. The default ranges for (out-of-the-box) dials objects are documented in dials.

@hfrick hfrick transferred this issue from tidymodels/dials Apr 27, 2023
@hfrick hfrick added the tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day label Jul 22, 2024
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants