-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add default plot for cox model * update NEWS.md * making sure mlr3proba doesn't break the CI * trying again --------- Co-authored-by: be-marc <marcbecker@posteo.de>
- Loading branch information
Showing
5 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#' @title Plots for Cox Proportional Hazards Learner | ||
#' | ||
#' @description | ||
#' Visualizations for [mlr3proba::LearnerSurvCoxPH]. | ||
#' | ||
#' The argument `type` controls what kind of plot is drawn. | ||
#' The only possible choice right now is `"ggforest"` (default) which is a | ||
#' Forest Plot, using [ggforest][survminer::ggforest()]. | ||
#' This plot displays the estimated hazard ratios (HRs) and their confidence | ||
#' intervals (CIs) for different variables included in the (trained) model. | ||
#' | ||
#' @param object ([mlr3proba::LearnerSurvCoxPH]). | ||
#' | ||
#' @template param_type | ||
#' @param ... Additional parameters passed down to `ggforest`. | ||
#' | ||
#' @return [ggplot2::ggplot()]. | ||
#' | ||
#' @export | ||
#' @examples | ||
#' \donttest{ | ||
#' if (requireNamespace("mlr3proba")) { | ||
#' library(mlr3proba) | ||
#' library(mlr3viz) | ||
#' | ||
#' task = tsk("lung") | ||
#' learner = lrn("surv.coxph") | ||
#' learner$train(task) | ||
#' autoplot(learner) | ||
#' } | ||
#' } | ||
autoplot.LearnerSurvCoxPH = function(object, type = "ggforest", ...) { | ||
assert_class(object, classes = "LearnerSurvCoxPH", null.ok = FALSE) | ||
assert_has_model(object) | ||
|
||
switch(type, | ||
"ggforest" = { | ||
require_namespaces("survminer") | ||
suppressWarnings(survminer::ggforest(object$model, ...)) | ||
}, | ||
|
||
stopf("Unknown plot type '%s'", type) | ||
) | ||
} | ||
|
||
#' @export | ||
plot.LearnerSurvCoxPH = function(x, ...) { | ||
print(autoplot(x, ...)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.