Skip to content

Instantly share code, notes, and snippets.

@RaphaelS1
Last active September 29, 2024 21:36
Show Gist options
  • Save RaphaelS1/53f602304b9d19124372c9e0d0130155 to your computer and use it in GitHub Desktop.
Save RaphaelS1/53f602304b9d19124372c9e0d0130155 to your computer and use it in GitHub Desktop.
## select holdout as the resampling strategy
resampling <- rsmp("cv", folds = 3)
## add KM and CPH
learners <- c(learners, lrns(c("surv.kaplan", "surv.coxph")))
design <- benchmark_grid(tasks, learners, resampling)
bm <- benchmark(design)
## Aggreggate with Harrell's C and Integrated Graf Score
msrs <- msrs(c("surv.cindex", "surv.graf"))
bm$aggregate(msrs)[, c(3, 4, 7, 8)]
@JianGuoZhou3
Copy link

JianGuoZhou3 commented Feb 19, 2022

@RaphaelS1 Thank you very much, Now it works in my MacBook.
image

@yuanyuan102
Copy link

@RaphaelS1 Thanks so much! The previous error disappeared after I updated the packages. But I just got a new error as here: "
UserWarning: Got event/censoring at start time. Should be removed! It is set s.t. it has no contribution to loss.
warnings.warn("""Got event/censoring at start time. Should be removed! It is set s.t. it has no contribution to loss.""")
INFO [02:01:53.669] [mlr3] Applying learner 'surv.pchazard' on task 'right_censored' (iter 3/3)
Error in FUN(newX[, i], ...) :
Survival probabilities must be (non-strictly) decreasing"
Could you please help me with that or shed some lights on it? Thanks in advance!

@RaphaelS1
Copy link
Author

Are you using your own data? It is saying that at t=0 there is an event (death or censoring). You should manually set that to a different time (e.g. 0.001) or remove the observation

@yuanyuan102
Copy link

Hi @RaphaelS1, Yes I am using my own data, I checked my data and all my time are >0. I wonder if you have any suggestions about the error message "Survival probabilities must be (non-strictly) decreasing" above. Thanks in advance!

@RaphaelS1
Copy link
Author

RaphaelS1 commented Feb 28, 2022

Ah apologies I saw the warning not the error. The error is saying that the predictions from your model are not valid survival probabilities. Unfortunately without access to your data I can't tell if the error is in my software, your code, or your data. I suggest you open an issue in the survivalmodels repo so we can figure it out properly

@lxtpvt
Copy link

lxtpvt commented May 6, 2023

Hi Raphael, first thanks for you work. It just what I needed. However, I'm encountering the error as follows. Do you know what's the reason? Thanks!

INFO [10:53:55.224] [bbotk] Evaluating 1 configuration(s)
INFO [10:53:55.254] [mlr3] Running benchmark with 1 resampling iterations
INFO [10:53:55.259] [mlr3] Applying learner 'surv.pchazard' on task 'lung' (iter 1/1)
INFO [10:53:55.300] [mlr3] Applying learner 'surv.kaplan' on task 'lung' (iter 1/3)
INFO [10:53:55.314] [mlr3] Applying learner 'surv.kaplan' on task 'lung' (iter 2/3)
INFO [10:53:55.328] [mlr3] Applying learner 'surv.kaplan' on task 'lung' (iter 3/3)
INFO [10:53:55.342] [mlr3] Applying learner 'surv.coxph' on task 'lung' (iter 1/3)
INFO [10:53:55.374] [mlr3] Applying learner 'surv.coxph' on task 'lung' (iter 2/3)
INFO [10:53:55.397] [mlr3] Applying learner 'surv.coxph' on task 'lung' (iter 3/3)
Error in py_call_impl(callable, dots$args, dots$keywords) :
RuntimeError: CUDA error: unspecified launch failure
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.

@RaphaelS1
Copy link
Author

Hey @lxtpvt this is an error on the pyrthon side, I think possibly you might just need to restart your session and the error will clear itself. Does this issue help? There's lots of other similar ones associated with pytorch if you Google "RuntimeError: CUDA error: unspecified launch failure"

@lxtpvt
Copy link

lxtpvt commented May 8, 2023

Thanks Raphael, I fixed this problem by upgrading the ''mlr3proba" package. However, this is another error from the "coxtime" model as follows.

Error in py_call_impl(callable, dots$args, dots$keywords) :
AttributeError: 'Series' object has no attribute 'iteritems'

This happened PipeOp surv.coxtime.tuned's $train()

When I remove the "coxtime" model from the learners list, everything is OK.

@RaphaelS1
Copy link
Author

Great! Strange I've never seen that error before... Looks like it's in the underlying {pycox} implementation. Maybe try reinstalling pycox?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment