Skip to content

Commit

Permalink
use model=TRUE in cox fit
Browse files Browse the repository at this point in the history
  • Loading branch information
bblodfon committed Dec 31, 2024
1 parent 93faac3 commit b43e7d6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# mlr3proba dev

* fix: `lrn("surv.coxph")` is now trained with `model=TRUE` which fixes an issue with using observation weights [stackoverflow link](https://stackoverflow.com/questions/79297386/mlr3-predicted-values-for-surv-coxph-learner-with-case-weights).

# mlr3proba 0.7.1

* cleanup: removed all `PipeOp`s and pipelines related to survival => regression reduction techniques (see #414)
Expand Down
2 changes: 1 addition & 1 deletion R/LearnerSurvCoxPH.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ LearnerSurvCoxPH = R6Class("LearnerSurvCoxPH",
}

invoke(survival::coxph, formula = task$formula(), data = task$data(),
.args = pv, x = TRUE)
.args = pv, model = TRUE)
},

.predict = function(task) {
Expand Down
13 changes: 1 addition & 12 deletions tests/testthat/test_mlr_learners_surv_coxph.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,11 @@ test_that("autotest", {
with_seed(42L, {
learner = lrn("surv.coxph")
expect_learner(learner)
## no idea why weights check here fails, we test the same task
## in the below test and it works!
result = suppressWarnings(
run_autotest(learner, exclude = "weights", check_replicable = FALSE, N = 10L)
)
result = run_autotest(learner, check_replicable = FALSE)
expect_true(result, info = result$error)
})
})

test_that("weights", {
learner = lrn("surv.coxph")
task = generate_tasks.LearnerSurv(learner)$weights
learner$train(task)
expect_equal(learner$model$weights, task$weights$weight)
})

test_that("missing", {
learner = lrn("surv.coxph")
lung = survival::lung
Expand Down

0 comments on commit b43e7d6

Please sign in to comment.