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

How to perform stacking of multiple survival learners #826

Open
TianshuGu opened this issue Jul 9, 2024 · 2 comments
Open

How to perform stacking of multiple survival learners #826

TianshuGu opened this issue Jul 9, 2024 · 2 comments

Comments

@TianshuGu
Copy link

library(data.table)
library(mlr3)
library(mlr3proba)
library(mlr3pipelines)
library(mlr3learners)
library(mlr3extralearners)
library(mlr3tuning)
library(mlr3benchmark)
library(glmnet)
library(ggplot2)
library(survex)
library(tidyr)
library(survival)
# remotes::install_github("mlr-org/mlr3filters")
library(mlr3filters)

data("lung", package = "survival")
data <- as.data.table(lung)

# 
data$time <- data$time / 30  # 将生存时间从天转换为月(可选)

#  
data <- data[, lapply(.SD, function(x) ifelse(is.na(x), median(x, na.rm = TRUE), x))]

 

#  
task <- TaskSurv$new(id = "lung_survival_task", backend = data,time = 'time',event = 'event')


# (Base Learners)
base_learners = lrns(c("surv.coxph", "surv.kaplan", "surv.cv_glmnet", "surv.xgboost"))

# (Super Learner)
super_learner = lrn("surv.ranger" )

# stacking
stacking = ppl("stacking",
               base_learners = base_learners,
               super_learner = super_learner
)

# training
stacking$train(lung_task)


###This is my error message

> stacking$train(lung_task)
INFO  [16:33:19.810] [mlr3] Applying learner 'surv.coxph' on task 'lung_survival_task' (iter 1/3)
INFO  [16:33:19.833] [mlr3] Applying learner 'surv.coxph' on task 'lung_survival_task' (iter 2/3)
INFO  [16:33:19.854] [mlr3] Applying learner 'surv.coxph' on task 'lung_survival_task' (iter 3/3)
INFO  [16:33:19.935] [mlr3] Applying learner 'surv.kaplan' on task 'lung_survival_task' (iter 1/3)
INFO  [16:33:19.946] [mlr3] Applying learner 'surv.kaplan' on task 'lung_survival_task' (iter 2/3)
INFO  [16:33:19.956] [mlr3] Applying learner 'surv.kaplan' on task 'lung_survival_task' (iter 3/3)
INFO  [16:33:20.241] [mlr3] Applying learner 'surv.cv_glmnet' on task 'lung_survival_task' (iter 1/3)
INFO  [16:33:20.402] [mlr3] Applying learner 'surv.cv_glmnet' on task 'lung_survival_task' (iter 2/3)
INFO  [16:33:20.580] [mlr3] Applying learner 'surv.cv_glmnet' on task 'lung_survival_task' (iter 3/3)
INFO  [16:33:20.839] [mlr3] Applying learner 'surv.xgboost' on task 'lung_survival_task' (iter 1/3)
INFO  [16:33:20.856] [mlr3] Applying learner 'surv.xgboost' on task 'lung_survival_task' (iter 2/3)
INFO  [16:33:20.871] [mlr3] Applying learner 'surv.xgboost' on task 'lung_survival_task' (iter 3/3)
Error: <TaskSurv:lung_survival_task> has the following unsupported feature types: list
This happened PipeOp surv.ranger's $train()
In addition: Warning messages:
1: In coxph.fit(X, Y, istrat, offset, init, control, weights = weights,  :
  Loglik converged before variable  8 ; coefficient may be infinite. 
This happened PipeOp surv.coxph.surv.coxph's $train()
2: In coxph.fit(X, Y, istrat, offset, init, control, weights = weights,  :
  Loglik converged before variable  8 ; coefficient may be infinite. 
This happened PipeOp surv.coxph.surv.coxph's $train()
3: In coxph.fit(X, Y, istrat, offset, init, control, weights = weights,  :
  Loglik converged before variable  8 ; coefficient may be infinite. 
This happened PipeOp surv.coxph.surv.coxph's $train()
4: In coxph.fit(X, Y, istrat, offset, init, control, weights = weights,  :
  Loglik converged before variable  8 ; coefficient may be infinite. 
This happened PipeOp surv.coxph.surv.coxph's $train()

This always happened on the super learner

@sebffischer
Copy link
Sponsor Member

@jemus42

@jemus42
Copy link
Sponsor Member

jemus42 commented Aug 15, 2024

I have not done any stacking yet, but the book has a section on that so I hope that helps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants