This function is a wrapper for plotting model_parts objects created for survival models using the model_parts() function.

# S3 method for model_parts_survival
plot(x, ...)

Arguments

x

an object of class "model_parts_survival" to be plotted

...

additional parameters passed to the plot.surv_feature_importance function

Value

An object of the class ggplot.

Plot options

  • title - character, title of the plot

  • subtitle - character, subtitle of the plot, if NULL automatically generated as "created for XXX, YYY models", where XXX and YYY are explainer labels

  • max_vars - maximum number of variables to be plotted (least important variables are ignored)

  • colors - character vector containing the colors to be used for plotting variables (containing either hex codes "#FF69B4", or names "blue")

  • rug - character, one of "all", "events", "censors", "none" or NULL. Which times to mark on the x axis in geom_rug().

  • rug_colors - character vector containing two colors (containing either hex codes "#FF69B4", or names "blue"). The first color (red by default) will be used to mark event times, whereas the second (grey by default) will be used to mark censor times.

See also

Other functions for plotting 'model_parts_survival' objects: plot.surv_feature_importance()

Examples

# \donttest{
library(survival)
library(survex)

model <- coxph(Surv(time, status) ~ ., data = veteran, x = TRUE, model = TRUE, y = TRUE)
explainer <- explain(model)
#> Preparation of a new explainer is initiated 
#>   -> model label       :  coxph (  default  ) 
#>   -> data              :  137  rows  6  cols (  extracted from the model  ) 
#>   -> target variable   :  137  values ( 128 events and 9 censored , censoring rate = 0.066 ) (  extracted from the model  ) 
#>   -> times             :  50 unique time points , min = 1.5 , median survival time = 80 , max = 999 
#>   -> times             :  (  generated from y as uniformly distributed survival quantiles based on Kaplan-Meier estimator  ) 
#>   -> predict function  :  predict.coxph with type = 'risk' will be used (  default  ) 
#>   -> predict survival function  :  predictSurvProb.coxph will be used (  default  ) 
#>   -> predict cumulative hazard function  :  -log(predict_survival_function) will be used (  default  ) 
#>   -> model_info        :  package survival , ver. 3.5.8 , task survival (  default  ) 
#>   A new explainer has been created!  

mp <- model_parts(explainer)

plot(mp)

# }