-
Notifications
You must be signed in to change notification settings - Fork 27
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
support "censored regression"
#152
Comments
Has there been any progress on this? I'm not successful with my attempts but maybe I'm doing something wrong. library(tidymodels)
library(censored)
#> Loading required package: survival
library(stacks)
library(finetune)
tidymodels_prefer()
data(cancer)
lung <- lung %>%
drop_na() %>%
tibble() %>%
mutate(surv = Surv(time, status))
lung_train <- lung %>% vfold_cv(strata = status, v = 5)
mod_glmnet <- proportional_hazards(penalty = tune(), mixture = tune()) %>%
set_engine("glmnet") %>%
set_mode("censored regression")
recipe_lung <- recipe(surv ~ ., data = lung) %>%
update_role(c(inst, time, status), new_role = "ID")
workflow_lung <- workflow() %>%
add_recipe(recipe_lung) %>%
add_model(mod_glmnet)
tune_glmnet <- workflow_lung %>%
tune_race_win_loss(
lung_train,
grid = 3,
eval_time = 365,
control = control_race(
save_pred = TRUE,
save_workflow = TRUE,
allow_par = FALSE
)
)
stack_lung <- stacks() %>%
add_candidates(tune_glmnet)
#> Error in `res[order(res$.row, res$.config), nms]`:
#> ! Can't subset columns that don't exist.
#> ✖ Columns `penalty` and `mixture` don't exist.
#> Backtrace:
#> ▆
#> 1. ├─stacks() %>% add_candidates(tune_glmnet)
#> 2. ├─stacks::add_candidates(., tune_glmnet)
#> 3. ├─stacks:::add_candidates.tune_results(., tune_glmnet)
#> 4. │ └─... %>% .set_data_candidates(candidates, name, col_name)
#> 5. ├─stacks:::.set_data_candidates(., candidates, name, col_name)
#> 6. │ ├─... %>% dplyr::select(-.row)
#> 7. │ └─stacks:::collate_predictions(candidates)
#> 8. │ ├─tune::collect_predictions(x, summarize = TRUE) %>% ...
#> 9. │ ├─tune::collect_predictions(x, summarize = TRUE)
#> 10. │ ├─finetune:::collect_predictions.tune_race(x, summarize = TRUE)
#> 11. │ ├─base::NextMethod(summarize = summarize, parameters = parameters)
#> 12. │ └─tune:::collect_predictions.tune_results(...)
#> 13. │ └─tune:::average_predictions(x, parameters)
#> 14. │ └─tune:::surv_summarize(x, param_names, y_nms)
#> 15. │ ├─res[order(res$.row, res$.config), nms]
#> 16. │ └─tibble:::`[.tbl_df`(res, order(res$.row, res$.config), nms)
#> 17. │ └─tibble:::vectbl_as_col_location(...)
#> 18. │ ├─tibble:::subclass_col_index_errors(...)
#> 19. │ │ └─base::withCallingHandlers(...)
#> 20. │ └─vctrs::vec_as_location(j, n, names, missing = "error", call = call)
#> 21. ├─dplyr::select(., -.row)
#> 22. ├─tidyr::pivot_wider(...)
#> 23. ├─dplyr::mutate(., .config = process_.config(.config, df = ., name = col_name))
#> 24. ├─dplyr::select(...)
#> 25. ├─dplyr::mutate(., .config = if (".config" %in% names(.)) .config else NA_character_)
#> 26. ├─dplyr::ungroup(.)
#> 27. ├─dplyr::rename_with(., make.names, .cols = dplyr::starts_with(".pred"))
#> 28. └─vctrs (local) `<fn>`()
#> 29. └─vctrs:::stop_subscript_oob(...)
#> 30. └─vctrs:::stop_subscript(...)
#> 31. └─rlang::abort(...) Created on 2023-12-28 with reprex v2.0.2 |
As far as I know, there haven't been much progress yet. But we are still planning to make it happen! |
This will actually be a good bit more complicated than the kinds of changes in #157. The added functionality from accounting for evaluation times throughout stacks' internals is likely not worth the complexity, unfortunately. |
Will need to come after workflows/workflowsets support, but--
A good bit of conditional statements based on the mode will need to be adjusted, to start off!🏄
stacks/R/add_candidates.R
Lines 185 to 186 in 227efb6
stacks/R/blend_predictions.R
Line 158 in 7822d86
stacks/R/print.R
Line 5 in 0b6306d
The text was updated successfully, but these errors were encountered: