How do I use grid search with the tidymodels package to determine the best lambda value for cox lasso regression

rm(list = ls()) 
options(stringsAsFactors = F)
Sys.setenv(LANGUAGE = "en")


data <- SimSurv(2000) %>% mutate(X2 = X2 + 1)

data_split <- initial_split(data, 
                            strata = event,
                            prop = 0.7)
data_train <- training(data_split)
data_test <- testing(data_split)

cox_spec <- proportional_hazards(penalty = tune(),mixture = 1) %>%

cv  <- vfold_cv(data = data_train,
                v = 10)

lambda_grid <- grid_regular(penalty(), levels = 50)

wf <- workflow() %>%
  add_formula(Surv(time, event) ~ X1 + X2)

lasso_grid <- tune_grid(
  wf %>% add_model(cox_spec),
  resamples = cv,
  grid = lambda_grid)

#Error in `check_metrics()`:
#! Unknown `mode` for parsnip model.

That's next on our list; censored isn't 100% integrated into tidymodels. We need to set up performance statistics and a few other things before that will work

Thanks a lot for your answer. Now the tidymodels package and mlr3 package in the R language are the two camps for machine learning algorithms.As far as I know, the mlr3 package has been able to complete the above algorithm and published the corresponding article, I very much hope that the tidymodels package can also be updated as soon as possible to support the survival data machine learning algorithm.

The following is the name of the article and its code address

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.