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
I'm having trouble with using groupwise metrics with finetune
Reproducible example
pacman::p_load(tidymodels, finetune)
data(ames)
diff_range<-function(x) {
diff(range(x$.estimate))
}
demographic_parity_<-
new_groupwise_metric(
fn=detection_prevalence,
name="demographic_parity",
aggregate=diff_range
)
m_set<- metric_set(demographic_parity_(Neighborhood))
set.seed(502)
ames_split<- initial_split(ames)
ames_train<- training(ames_split)
ames_folds<- vfold_cv(ames_train, v=10)
rf_model<-
rand_forest(trees= tune()) %>%
set_engine("ranger") %>%
set_mode("classification")
rf_wflow<-
workflow() %>%
add_formula(
Lot_Shape~Year_Built+Bldg_Type+Latitude+Longitude
) %>%
add_model(rf_model)
grid<- parameters(trees(c(10, 100))) %>%
grid_max_entropy(size=10)
tune_res_anova<- tune_race_anova(
rf_wflow,
ames_folds,
grid=grid,
metrics=m_set
)
#> Warning in max(best_config$B, na.rm = TRUE): no non-missing arguments to max;#> returning -Inf#> Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]): contrasts can be applied only to factors with 2 or more levels#> Warning: package 'ranger' was built under R version 4.2.3#> Warning: package 'rlang' was built under R version 4.2.3#> Warning in max(best_config$B, na.rm = TRUE): no non-missing arguments to max;#> returning -Inf#> Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]): contrasts can be applied only to factors with 2 or more levels
Just noting that I can reproduce this and 1) don't see the failure with tune_grid() nor 2) with detection_prevalence on its own! Will revisit this when we're focused in on the package again—thanks for the reprex.
The problem
I'm having trouble with using groupwise metrics with finetune
Reproducible example
Created on 2024-08-30 with reprex v2.0.2
Session info
The text was updated successfully, but these errors were encountered: