Skip to content

Conversation

topepo
Copy link
Member

@topepo topepo commented Aug 1, 2025

Closes #248 and closes #249

The new results:

library(tidymodels)
library(stacks)
#> Registered S3 method overwritten by 'butcher':
#>   method                 from    
#>   as.character.dev_topic generics

data("penguins")

# change the species so that it has a - in it
dat <- penguins %>%
  mutate(species = paste0(species, "-1"))

# tune a glmnet model w 3 penalties
tuned <- recipe(species ~ bill_length_mm + bill_depth_mm +
                  flipper_length_mm, data = dat) %>%
  step_impute_mean(all_numeric_predictors()) %>%
  workflow(multinom_reg(engine = "glmnet", penalty = tune())) %>%
  tune_grid(dat %>% vfold_cv(3),
            metrics = metric_set(mn_log_loss),
            grid = crossing(penalty = c(.0001, .001, .01)),
            control = control_stack_grid())

data_st <- stacks() %>%
  add_candidates(tuned)

colnames(data_st)
#>  [1] "species"                               
#>  [2] ".pred_Adelie.1_tunedpre0_mod1_post0"   
#>  [3] ".pred_Adelie.1_tunedpre0_mod2_post0"   
#>  [4] ".pred_Adelie.1_tunedpre0_mod3_post0"   
#>  [5] ".pred_Chinstrap.1_tunedpre0_mod1_post0"
#>  [6] ".pred_Chinstrap.1_tunedpre0_mod2_post0"
#>  [7] ".pred_Chinstrap.1_tunedpre0_mod3_post0"
#>  [8] ".pred_Gentoo.1_tunedpre0_mod1_post0"   
#>  [9] ".pred_Gentoo.1_tunedpre0_mod2_post0"   
#> [10] ".pred_Gentoo.1_tunedpre0_mod3_post0"

Created on 2025-08-01 with reprex v2.1.1

@topepo topepo requested a review from simonpcouch August 1, 2025 20:21
@topepo topepo marked this pull request as ready for review August 4, 2025 18:10
Copy link
Contributor

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the PR description, it seems like you're writing that stacks "just works" with the new config ids?

I do see this error in the CRAN R-CMD-check:

══ Failed ══════════════════════════════════════════════════════════════════════
── 1. Failure ('test-stacks-columns.R:43:3'): stacks can accommodate outcome lev
".pred_Adelie.1_tunedpre0_mod2_post0" %in% colnames(data_st) is not TRUE

`actual`:   FALSE
`expected`: TRUE 

And a good few in the GH check.

@EmilHvitfeldt
Copy link
Member

The error that simon found has been addressed in 61c62ec

@EmilHvitfeldt EmilHvitfeldt merged commit 75e6cdc into main Aug 14, 2025
0 of 5 checks passed
@EmilHvitfeldt EmilHvitfeldt deleted the stacking-config-name branch August 14, 2025 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

melodie-switch: stacking with finetune breaks melodie-switch: Change in .config affects column names while stacking
3 participants