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

Harmonize message text about eval_time being ignored #811

Closed
hfrick opened this issue Jan 16, 2024 · 2 comments · Fixed by #847
Closed

Harmonize message text about eval_time being ignored #811

hfrick opened this issue Jan 16, 2024 · 2 comments · Fixed by #847

Comments

@hfrick
Copy link
Member

hfrick commented Jan 16, 2024

I prefer the version that explicitly says the eval_time argument will be ignored.

Part of #704, wait till we've got that all done?

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

lung_surv <- lung %>% 
  dplyr::mutate(surv = Surv(time, status), .keep = "unused")

# mode is not censored regression 
set.seed(2193)
tune_res <-
  linear_reg(penalty = tune(), engine = "glmnet") %>%
  tune_grid(
    mpg ~ .,
    resamples = vfold_cv(mtcars, 2),
    metrics = metric_set(rmse),
    grid = 2, 
    eval_time = 10
  )
#> Warning in tune_grid(wflow, resamples = resamples, param_info = param_info, : Evaluation times are only required when the model mode is "censored regression"
#> (and will be ignored).
sb <- show_best(tune_res, metric = "rmse", eval_time = 10)
#> Warning in show_best(tune_res, metric = "rmse", eval_time = 10): Evaluation times are only required when the model mode is "censored regression"
#> (and will be ignored).

# non-dynamic metric 
set.seed(2193)
tune_res <-
  proportional_hazards(penalty = tune(), engine = "glmnet") %>%
  tune_grid(
    surv ~ .,
    resamples = vfold_cv(lung_surv, 2),
    grid = 2,
    metrics = metric_set(concordance_survival, brier_survival_integrated),
    eval_time = c(10, 20)
  )
sb <- show_best(tune_res, eval_time = 10, metric = "concordance_survival")
#> Warning in show_best(tune_res, eval_time = 10, metric = "concordance_survival"): An evaluation time is only required when a dynamic metric is selected (and
#> `eval_time` will thus be ignored).

Created on 2024-01-16 with reprex v2.0.2

@hfrick
Copy link
Member Author

hfrick commented Jan 16, 2024

Another variation of the text, here from int_pctl.tune_results() (errors logged separately at #812 and #813)

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

lung_surv <- lung %>%
  dplyr::mutate(surv = Surv(time, status), .keep = "unused")

# mode is not censored regression
set.seed(2193)
tune_res <-
  linear_reg(penalty = tune(), engine = "glmnet") %>%
  tune_grid(
    mpg ~ .,
    resamples = vfold_cv(mtcars, 2),
    metrics = metric_set(rmse),
    grid = 2,
    control = control_grid(save_pred = TRUE)
  )
foo <- int_pctl(tune_res, metrics = "rmse", times = 2, eval_time = 10)
#> Warning: The 'eval_time' argument is not needed for this data set.
#> Error in `purrr::map2()`:
#> ℹ In index: 1.
#> Caused by error in `check_tidy()`:
#> ! `statistics` should select a list column of tidy results.

# non-dynamic metric
set.seed(2193)
tune_res <-
  proportional_hazards(penalty = tune(), engine = "glmnet") %>%
  tune_grid(
    surv ~ .,
    resamples = vfold_cv(lung_surv, 2),
    grid = 2,
    control = control_grid(save_pred = TRUE),
    metrics = metric_set(concordance_survival, brier_survival_integrated),
    eval_time = c(10, 20)
  )

foo <- int_pctl(tune_res, times = 2, eval_time = 10, metrics = "concordance_survival")
#> Warning: The 'eval_time' argument is not needed for this data set.
#> Error in `purrr::map2()`:
#> ℹ In index: 1.
#> Caused by error in `dplyr::rename()`:
#> ! Can't rename columns that don't exist.
#> ✖ Column `term` doesn't exist.

foo <- int_pctl(tune_res, times = 2, eval_time = 10, metrics = "brier_survival_integrated")
#> Warning: The 'eval_time' argument is not needed for this data set.
#> Error in `purrr::map2()`:
#> ℹ In index: 1.
#> Caused by error in `dplyr::rename()`:
#> ! Can't rename columns that don't exist.
#> ✖ Column `term` doesn't exist.

Created on 2024-01-16 with reprex v2.0.2

Copy link

github-actions bot commented Mar 6, 2024

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.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant