Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix printing for evaluation time for survival models #84

Merged
merged 2 commits into from
Nov 14, 2023
Merged

fix printing for evaluation time for survival models #84

merged 2 commits into from
Nov 14, 2023

Conversation

EmilHvitfeldt
Copy link
Member

@EmilHvitfeldt EmilHvitfeldt commented Nov 14, 2023

to close #81

bug turned out to be a simple typo

library(tidymodels)
library(finetune)
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)

set.seed(2)
split <- initial_split(sim_dat)
sim_tr <- training(split)
sim_te <- testing(split)
sim_rs <- bootstraps(sim_tr, times = 4)

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

mod_spec <-
  decision_tree(cost_complexity = tune()) %>%
  set_mode("censored regression")

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

gctrl <- control_grid(save_pred = TRUE)
rctrl <- control_race(save_pred = TRUE, verbose_elim = TRUE, verbose = FALSE)

dyn_mtrc  <- metric_set(brier_survival)

set.seed(2193)
aov_dyn_res <-
  mod_spec %>%
  tune_race_anova(
    event_time ~ X1 + X2,
    resamples = sim_rs,
    grid = grid,
    metrics = dyn_mtrc,
    eval_time = time_points,
    control = rctrl
  )
#> ℹ Racing will minimize the brier_survival metric at time 10.
#> ℹ Resamples are analyzed in a random order.
#> ℹ Bootstrap4: 0 eliminated; 3 candidates remain.

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

@topepo topepo self-requested a review November 14, 2023 11:22
@@ -248,7 +248,7 @@ tune_race_anova_workflow <-
metric_info <- tibble::as_tibble(metrics)
analysis_metric <-metric_info$metric[1]
analysis_max <- metric_info$direction[1] == "maximize"
is_dyn <- metric_info$direction[1] == "dynamic_survival_metric"
is_dyn <- metric_info$class[1] == "dynamic_survival_metric"
Copy link
Member

Choose a reason for hiding this comment

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

image

@topepo topepo merged commit 300e0e2 into main Nov 14, 2023
8 checks passed
@topepo topepo deleted the fix81 branch November 14, 2023 11:23
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.

name the evaluation time for survival models
2 participants