tidymodels / tune

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

Avoid warning from `geom_line()` bubbling up in `autoplot()`? #755

Closed hfrick closed 8 months ago

hfrick commented 1 year ago

Do we want to try to avoid that warning from geom_line()?

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

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

sim_rs <- vfold_cv(sim_dat)

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

mod_spec <-
  decision_tree(tree_depth = tune(), min_n = 4) %>%
  set_engine("partykit") %>%
  set_mode("censored regression")

sint_mtrc <- metric_set(brier_survival_integrated)

grid <- tibble(tree_depth = c(1, 2, 10))
rctrl <- control_race(save_pred = TRUE, verbose_elim = FALSE, verbose = FALSE)

set.seed(2193)
aov_integrated_res <-
  mod_spec %>%
  tune_race_anova(
    event_time ~ X1 + X2,
    resamples = sim_rs,
    grid = grid,
    metrics = sint_mtrc,
    eval_time = time_points,
    control = rctrl
  )

autoplot(aov_integrated_res, eval_time = 10) 
#> `geom_line()`: Each group consists of only one observation.
#> ℹ Do you need to adjust the group aesthetic?

Created on 2023-07-28 by the reprex package (v2.0.1)

topepo commented 10 months ago

The code for this is in tune so I'll move it there.

topepo commented 10 months ago

The offending code is in tune:::plot_marginals()

topepo commented 8 months ago

Let's detect this and then error with an explanation.

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.