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
The functions step_smote from {themis} and nearest_neighbor from {parsnip} have a common tuning parameter called neighbors. When I try to tune both hyperparameters in a workflow, I receive an error about duplicated item. Is there a way to 'rename' a hyperparameter?
Bellow a reprex:
library(tidymodels)
library(themis)
library(palmerpenguins)
#> #> Attaching package: 'palmerpenguins'#> The following object is masked from 'package:modeldata':#> #> penguinsp_split<- initial_split(data=penguins|> drop_na(), strata=species)
folds<- vfold_cv(data= training(p_split), strata=species)
rec<- recipe(species~bill_length_mm+bill_depth_mm, data= training(p_split)) |>
step_smote(species, over_ratio= tune(), neighbors= tune())
rf_spec<-
rand_forest(
trees= tune(),
min_n= tune()
) |>
set_engine("ranger") |>
set_mode("classification")
knn_spec<-
nearest_neighbor(
neighbors= tune(),
dist_power= tune()
) |>
set_engine("kknn") |>
set_mode("classification")
wf_set<- workflow_set(
preproc=list(rec),
models=list(
rf=rf_spec,
knn=knn_spec
),
cross=TRUE
)
tune_res<-wf_set|>
workflow_map(
"tune_grid",
resamples=folds,
grid=10,
verbose=TRUE
)
#> i 1 of 2 tuning: recipe_rf#> ✔ 1 of 2 tuning: recipe_rf (9.9s)#> i 2 of 2 tuning: recipe_knn#> ✖ 2 of 2 tuning: recipe_knn failed with: Error in hardhat::extract_parameter_set_dials(wflow) : Element `id` should have unique values. Duplicates exist for item(s): 'neighbors'
In cases were we need to tune the same parameter multiple times, like here with neighbors, can we use the id argument of tune() to distinguish them. I'm adding tune("neighbors_smote") below in step_smote() to denote it to be different than the tune()used innearest_neighbor()`
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.
Hi!
The functions
step_smote
from {themis} andnearest_neighbor
from {parsnip} have a common tuning parameter calledneighbors
. When I try to tune both hyperparameters in a workflow, I receive an error about duplicated item. Is there a way to 'rename' a hyperparameter?Bellow a reprex:
Created on 2024-02-22 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: