Skip to content

Commit

Permalink
add examples for scoring rules
Browse files Browse the repository at this point in the history
  • Loading branch information
bblodfon committed Dec 18, 2024
1 parent 1ddba16 commit 20aa360
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/MeasureSurvCindex.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#'
#' # Harrell's C-index evaluated up to a specific time horizon
#' p$score(msr("surv.cindex", t_max = 97))
#'
#' # Harrell's C-index evaluated up to the time corresponding to 30% of censoring
#' p$score(msr("surv.cindex", p_max = 0.3))
#'
Expand Down
1 change: 1 addition & 0 deletions R/MeasureSurvGraf.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#'
#' @family Probabilistic survival measures
#' @family distr survival measures
#' @template example_scoring_rules
#' @export
MeasureSurvGraf = R6Class("MeasureSurvGraf",
inherit = MeasureSurv,
Expand Down
1 change: 1 addition & 0 deletions R/MeasureSurvIntLogloss.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#'
#' @family Probabilistic survival measures
#' @family distr survival measures
#' @template example_scoring_rules
#' @export
MeasureSurvIntLogloss = R6Class("MeasureSurvIntLogloss",
inherit = MeasureSurv,
Expand Down
1 change: 1 addition & 0 deletions R/MeasureSurvSchmid.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#'
#' @family Probabilistic survival measures
#' @family distr survival measures
#' @template example_scoring_rules
#' @export
MeasureSurvSchmid = R6Class("MeasureSurvSchmid",
inherit = MeasureSurv,
Expand Down
45 changes: 45 additions & 0 deletions man-roxygen/example_scoring_rules.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#' <% measure = suppressWarnings(get(fullname)$new()) %>
#'
#' @examples
#' library(mlr3)
#'
#' # Define a survival Task
#' task = tsk("lung")
#'
#' # Create train and test set
#' part = partition(task)
#'
#' # Train Cox learner on the train set
#' cox = lrn("surv.coxph")
#' cox$train(task, row_ids = part$train)
#'
#' # Make predictions for the test set
#' p = cox$predict(task, row_ids = part$test)
#'
#' # <%=improper_id%>, G(t) calculated using the test set
#' p$score(msr("<%=measure$id%>"))
#'
#' # <%=improper_id%>, G(t) calculated using the train set (always recommended)
#' p$score(msr("<%=measure$id%>"), task = task, train_set = part$train)
#'
#' # <%=improper_id%>, ERV score (comparing with KM baseline)
#' p$score(msr("<%=measure$id%>", ERV = TRUE), task = task, train_set = part$train)
#'
#' # <%=improper_id%> at specific time point
#' p$score(msr("<%=measure$id%>", times = 365), task = task, train_set = part$train)
#'
#' # <%=improper_id%> at multiple time points (integrated)
#' p$score(msr("<%=measure$id%>", times = c(125, 365, 450), integrated = TRUE), task = task, train_set = part$train)
#'
#' # <%=improper_id%>, use time cutoff
#' p$score(msr("<%=measure$id%>", t_max = 700), task = task, train_set = part$train)
#'
#' # <%=improper_id%>, use time cutoff and also remove observations
#' p$score(msr("<%=measure$id%>", t_max = 700, remove_obs = TRUE), task = task, train_set = part$train)
#'
#' # <%=improper_id%>, use time cutoff corresponding to specific proportion of censoring on the test set
#' p$score(msr("<%=measure$id%>", p_max = 0.8), task = task, train_set = part$train)
#'
#' # <%=proper_id%>, G(t) calculated using the train set
#' p$score(msr("<%=measure$id%>", proper = TRUE), task = task, train_set = part$train)
#'
1 change: 1 addition & 0 deletions man/mlr_measures_surv.cindex.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions man/mlr_measures_surv.graf.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions man/mlr_measures_surv.intlogloss.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions man/mlr_measures_surv.schmid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 20aa360

Please sign in to comment.