You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using tidymodels for a survial prediction task. My data has very few events so I want to make sure the validation split is stratified by the event variable. However, this seems to no be implemented currently.
Here is an example:
# example data
library(survival)
attach(kidney)
kidney<-kidney %>%
mutate(
kidney_surv= Surv(time, status),
.keep="unused"
)
kidney_split<- initial_validation_split(kidney, strata=kidney_surv)
I do get the following error message: strata cannot be a Surv object. Use the time or event variable directly.
But it is unclear to me how it is supposed to work. None of these work:
This is indeed a little bumpy. We have an issue to revisit this when we feel comfortable that we have a good solution: #445 .
Our current idea is to remove the original time and status variables not when you make the Surv object but rather after you've made your resampling object, i.e., in a recipe:
library(rsample)
library(recipes)
# [...]
library(survival)
attach(kidney)
kidney<-kidney %>%
mutate(
surv= Surv(time, status) # keep the original variables here
)
# so you can use them for stratificationkidney_split<- initial_validation_split(kidney, strata=status)
# then remove them in your recipekidney_rec<- recipe(surv~., data= training(kidney_split)) %>%
step_rm(time, status)
Hi,
I'm using tidymodels for a survial prediction task. My data has very few events so I want to make sure the validation split is stratified by the event variable. However, this seems to no be implemented currently.
Here is an example:
I do get the following error message:
strata
cannot be aSurv
object. Use the time or event variable directly.But it is unclear to me how it is supposed to work. None of these work:
The text was updated successfully, but these errors were encountered: