-
-
Notifications
You must be signed in to change notification settings - Fork 20
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Using xgboost with crankcompositor
#363
Comments
Hi, please consult the crankcompose docs. Practically you will do something like:
But note that in general in survival analysis, there are issues when trying to compose the |
@fa1999abdi question covered? |
@bblodfon ,Thank you so much for your response. |
You should use |
crankcompositor
[Question]
crankcompositor
[Question]crankcompositor
@fa1999abdi I am going to soon split the xgboost objectives/learners (Cox vs AFT are very different) and for the Cox, the |
but it didn't work tsk_s <- as_task_surv(tb, time = "time_to_death", event = "status", type = "right")
pipe = po("imputehist") %>>%
ppl("crankcompositor", learner = lrn("surv.xgboost"), response = TRUE, method = "sum_haz")
pipe$train(tsk_s)
p = pipe$predict(tsk_s)[[1]] # p will have a response (survival time) now
$compose_crank.output
NULL
> p = pipe$predict(tsk_s)[[1]] # p will have a response (survival time) now
Error: Assertion on 'distr' failed: FALSE.
This happened PipeOp compose_crank's $predict()
` |
Yes, you need to estimate the library(mlr3proba)
#> Loading required package: mlr3
library(mlr3pipelines)
library(mlr3extralearners)
task = tsk("rats")
learner =
po("encode", method = "treatment") %>>%
ppl("crankcompositor",
# crank needs a distr prediction type, xgboost doesn't have one, so we have to estimate it:
learner = ppl("distrcompositor", learner = lrn("surv.xgboost", nrounds = 10),
estimator = "breslow", overwrite = FALSE),
response = TRUE, method = "sum_haz", overwrite = FALSE) |>
as_learner()
learner$train(task)
p = learner$predict(task)
p
#> <PredictionSurv> for 300 observations:
#> row_ids time status crank lp response distr
#> 1 101 FALSE -0.5318943 -0.5318943 3.987942 <list[1]>
#> 2 49 TRUE -0.9984229 -0.9984229 2.501140 <list[1]>
#> 3 104 FALSE -0.9984229 -0.9984229 2.501140 <list[1]>
#> ---
#> 298 92 FALSE -1.0661759 -1.0661759 2.337293 <list[1]>
#> 299 104 FALSE -0.8688244 -0.8688244 2.847226 <list[1]>
#> 300 102 FALSE -0.8688244 -0.8688244 2.847226 <list[1]>
p$score(msr("surv.cindex")) # uses lp prediction type
#> surv.cindex
#> 0.8984875
p$score(msr("surv.rmse")) # uses response prediction type
#> surv.rmse
#> 61.24336
p$score(msr("surv.brier")) # uses distr prediction type
#> surv.graf
#> 0.03333211 Created on 2024-02-10 with reprex v2.0.2 |
@bblodfon thanks so much for your help. |
FYI, even though you can do the above and get a |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hello
I'm doing ML survival study using the {MLR3proba} package, and I'm using three learners, "surv.rfsrc", "surv.xgboost" and "surv.penalized". I want to predict survival time for each individual and compare my three learners(with RMSE and C-index criteria). Would you please explain how can I use {mlr3pipelines} and {distrcompositor, crankcompositor} to do that?
The following are my codes:
Created on 2024-02-06 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: