Closed
Description
stacks currently fails when a classification
outcome name is class
. The issue arises here:
Lines 282 to 285 in 4843385
The logic here selects class probability predictions and the true outcome and gets rid of columns with .pred_class
(i.e. the columns with hard class predictions), as the ensemble doesn't make use of hard class predictions in stacking models. {tune} (or some other dependency) labels hard class prediction columns as .pred_colname
.
library(tidymodels)
library(workflowsets)
library(stacks)
# need devel modeldata for sim_classification
# devtools::install_github("tidymodels/modeldata")
library(modeldata)
x <- sim_classification(100)
spec_lasso <-
logistic_reg(engine = 'glmnet', penalty = tune(), mixture = 1)
rec <-
recipe(class ~ ., x) %>%
step_normalize(all_numeric_predictors())
res <- tune_grid(
spec_lasso,
preprocessor = rec,
resamples = vfold_cv(x, 2),
grid = 2,
control = control_stack_grid()
)
stacks() %>%
add_candidates(res) %>%
blend_predictions()
#> x Bootstrap01: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap02: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap03: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap04: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap05: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap06: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap07: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap08: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap09: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap10: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap11: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap12: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap13: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap14: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap15: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap16: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap17: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap18: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap19: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap20: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap21: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap22: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap23: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap24: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> x Bootstrap25: preprocessor 1/1, model 1/1: Error in glmnet::glmnet(x = maybe_matrix(x)...
#> Warning: All models failed. See the `.notes` column.
#> Error in `estimate_tune_results()` at tune/R/select_best.R:75:2:
#> ! All of the models failed. See the .notes column.
Created on 2022-04-28 by the reprex package (v2.0.1)
stacks ought to handle that column selecting more elegantly.
Reported in #120.
Metadata
Metadata
Assignees
Labels
No labels