tidymodels / tune

Tools for tidy parameter tuning
https://tune.tidymodels.org
Other
272 stars 42 forks source link

`augment()` for censored tune_results objects doesn't let you pass `eval_time` to `select_best()` #762

Closed EmilHvitfeldt closed 8 months ago

EmilHvitfeldt commented 9 months ago

what the title says. This is right now represented as the warning

library(tidymodels)
library(censored)
#> Loading required package: survival

set.seed(1)
sim_dat <- prodlim::SimSurv(500) %>%
  mutate(event_time = Surv(time, event)) %>%
  select(event_time, X1, X2) %>%
  as_tibble()

set.seed(2)
split <- initial_split(sim_dat)
sim_tr <- training(split)
sim_te <- testing(split)
sim_rs <- vfold_cv(sim_tr)

time_points <- c(10, 1, 5, 15)

mod_spec <-
  proportional_hazards(penalty = tune(), mixture = 1) %>%
  set_engine("glmnet") %>%
  set_mode("censored regression")

grid <- tibble(penalty = 10^c(-4, -2, -1))

gctrl <- control_grid(save_pred = TRUE)

# Grid search with a mixture of metrics --------------------------------------

mix_mtrc <- metric_set(brier_survival, brier_survival_integrated, concordance_survival)

set.seed(2193)
tune_res <-
  mod_spec %>%
  tune_grid(
    event_time ~ X1 + X2,
    resamples = sim_rs,
    grid = grid,
    metrics = mix_mtrc,
    eval_time = time_points,
    control = gctrl
  )

rune_res_aug <- augment(tune_res)
#> Warning: No evaluation time was set; a value of 5 was used.

Created on 2023-11-20 with reprex v2.0.2

hfrick commented 9 months ago

Now part of #766

github-actions[bot] commented 7 months ago

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.