-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Description
Would it be possible or worthwhile to update some of the variables in tree_frogs to be factors, specifically the ones that we use as outcomes for classification examples? This is necessary for computing metrics and would be nice if it were in the built-in data:
library(tidymodels)
library(stacks)
tree_frogs_class <-
tree_frogs %>%
dplyr::select(-c(clutch, latency))
tree_frogs_class_split <- initial_split(tree_frogs_class)
tree_frogs_class_train <- training(tree_frogs_class_split)
tree_frogs_class_test <- testing(tree_frogs_class_split)
log_st <-
stacks() %>%
add_candidates(log_res_nn) %>%
add_candidates(log_res_rf) %>%
blend_predictions() %>%
fit_members()
augment(log_st, tree_frogs_class_test) %>%
conf_mat(hatched, .pred_class)
#> Error in `yardstick_table()`:
#> ! `truth` must be a factor.
#> ℹ This is an internal error that was detected in the yardstick package.
#> Please report it at <https://github.com/tidymodels/yardstick/issues> with a reprex (<https://https://tidyverse.org/help/>) and the full backtrace.
#> Backtrace:
#> ▆
#> 1. ├─augment(log_st, tree_frogs_class_test) %>% ...
#> 2. ├─yardstick::conf_mat(., hatched, .pred_class)
#> 3. └─yardstick:::conf_mat.data.frame(., hatched, .pred_class)
#> 4. └─yardstick:::yardstick_table(truth = truth, estimate = estimate, case_weights = case_weights)
#> 5. └─rlang::abort("`truth` must be a factor.", .internal = TRUE)Created on 2023-01-25 with reprex v2.0.2
I suspect you did this manually when creating the example/test objects like log_res_nn? For example, when I see this in hatched:
library(tidymodels)
library(stacks)
log_res_nn %>%
collect_predictions()
#> # A tibble: 909 × 7
#> id .pred_no .pred_yes .row .pred_class hatched .config
#> <chr> <dbl> <dbl> <int> <fct> <fct> <chr>
#> 1 Fold1 0.469 0.531 1 yes yes Preprocessor1_Model1
#> 2 Fold1 0.725 0.275 5 no no Preprocessor1_Model1
#> 3 Fold1 0.572 0.428 16 no no Preprocessor1_Model1
#> 4 Fold1 0.721 0.279 17 no no Preprocessor1_Model1
#> 5 Fold1 0.503 0.497 28 no no Preprocessor1_Model1
#> 6 Fold1 0.689 0.311 29 no no Preprocessor1_Model1
#> 7 Fold1 0.464 0.536 31 yes no Preprocessor1_Model1
#> 8 Fold1 0.270 0.730 32 yes yes Preprocessor1_Model1
#> 9 Fold1 0.270 0.730 35 yes yes Preprocessor1_Model1
#> 10 Fold1 0.495 0.505 38 yes no Preprocessor1_Model1
#> # … with 899 more rowsCreated on 2023-01-25 with reprex v2.0.2
Metadata
Metadata
Assignees
Labels
No labels