You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Very new to tidymodels so bear with me. Following this example, I want to perform a random forest regression. The difference is that because I have spatial data (points) I am using the spatialsample package for resampling. All works well using the default parameters for the random forest (RF) model. So, when I do:
But when I try to fine tune the model parameters, like so:
recipe <- recipes::recipe(eq1, data = sf::st_drop_geometry(ames_sf))
# modeling
ranger_spec <-
rand_forest(mtry = tune(), min_n = tune(), trees = 501) %>% # in this line is the difference with the above code
set_mode("regression") %>%
set_engine("ranger")
ranger_workflow <-
workflow(recipe, ranger_spec) |>
tune::fit_resamples(folds)
I'm getting this error:
Error:
! 2 arguments have been tagged for tuning in these components: model_spec.
Please use one of the tuning functions (e.g. `tune_grid()`) to optimize them.
ranger_tune<-
tune_grid(ranger_workflow,
tune::fit_resamples(folds), # or resamples = tune::fit_resamples(folds)grid=5
)
was because the second argument meeds to be a the resampling folds you created with spatial_block_cv(), and tune::fit_resamples(folds) doesn't give you that.
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.
Very new to
tidymodels
so bear with me. Following this example, I want to perform a random forest regression. The difference is that because I have spatial data (points) I am using thespatialsample
package for resampling. All works well using the default parameters for the random forest (RF) model. So, when I do:everything's okay.
But when I try to fine tune the model parameters, like so:
I'm getting this error:
Moreover, I tried something like this:
I am getting this error:
But, if I type:
It works but I am not sure if that's the right way.
Could you please help me on how could I tune the hyperparameters of the RF model using spatial resampling strategy?
The complete code I am using up to the point I am creating the
recipe
(for the other part please see the above tries):Here is a small subset:
R
4.3.1,RStudio
2023.09.0 Build 463, Windows 10.The text was updated successfully, but these errors were encountered: