Skip to contents

Generates plots for TaskSurv, depending on argument type:

  • "target": Calls GGally::ggsurv() on a survival::survfit() object. This computes the Kaplan-Meier survival curve for the observations if this task.

  • "duo": Passes data and additional arguments down to GGally::ggduo(). columnsX is target, columnsY is features.

  • "pairs": Passes data and additional arguments down to GGally::ggpairs(). Color is set to target column.

Usage

# S3 method for TaskSurv
autoplot(
  object,
  type = "target",
  theme = theme_minimal(),
  reverse = FALSE,
  ...
)

Arguments

object

(TaskSurv).

type

(character(1)):
Type of the plot. See above for available choices.

theme

(ggplot2::theme())
The ggplot2::theme_minimal() is applied by default to all plots.

reverse

(logical())
If TRUE and type = 'target', it plots the Kaplan-Meier curve of the censoring distribution. Default is FALSE.

...

(any): Additional arguments. rhs is passed down to $formula of TaskSurv for stratification for type "target". Other arguments are passed to the respective underlying plot functions.

Value

ggplot2::ggplot() object.

Examples

library(mlr3)
library(mlr3viz)
library(mlr3proba)
library(ggplot2)

task = tsk("lung")

head(fortify(task))
#>     time status   age  inst meal.cal pat.karno ph.ecog ph.karno    sex wt.loss
#>    <int>  <int> <int> <int>    <int>     <int>   <int>    <int> <fctr>   <int>
#> 1:   306      1    74     3     1175       100       1       90      m      NA
#> 2:   455      1    68     3     1225        90       0       90      m      15
#> 3:  1010      0    56     3       NA        90       0       90      m      15
#> 4:   210      1    57     5     1150        60       1       90      m      11
#> 5:   883      1    60     1       NA        90       0      100      m       0
#> 6:  1022      0    74    12      513        80       1       50      m       0
autoplot(task) # KM

autoplot(task) # KM of the censoring distribution

autoplot(task, rhs = "sex")

autoplot(task, type = "duo")
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: Removed 1 row containing non-finite outside the scale range (`stat_smooth()`).
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 1 row containing non-finite outside the scale range (`stat_smooth()`).
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 47 rows containing non-finite outside the scale range
#> (`stat_smooth()`).
#> Warning: Removed 47 rows containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 47 rows containing non-finite outside the scale range
#> (`stat_smooth()`).
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: Removed 47 rows containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 3 rows containing non-finite outside the scale range (`stat_smooth()`).
#> Warning: Removed 3 rows containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 3 rows containing non-finite outside the scale range (`stat_smooth()`).
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: Removed 3 rows containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 1 row containing non-finite outside the scale range (`stat_smooth()`).
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 1 row containing non-finite outside the scale range (`stat_smooth()`).
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 1 row containing non-finite outside the scale range (`stat_smooth()`).
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 1 row containing non-finite outside the scale range (`stat_smooth()`).
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 14 rows containing non-finite outside the scale range
#> (`stat_smooth()`).
#> Warning: Removed 14 rows containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning: Removed 14 rows containing non-finite outside the scale range
#> (`stat_smooth()`).
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: pseudoinverse used at -0.005
#> Warning: neighborhood radius 1.005
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 1.01
#> Warning: Removed 14 rows containing missing values or values outside the scale range
#> (`geom_point()`).