The ceteris_paribus() function computes the predictions for the neighbor of our chosen observation. The neighbour is defined as the observations with changed value of one of the variable.

ceteris_paribus(explainer, observation, grid_points = 5,
  selected_variables = NULL)

Arguments

explainer

a model to be explained, preprocessed by the 'survxai::explain' function

observation

a new observation for which predictions need to be explained

grid_points

grid_points number of points used for response path

selected_variables

if specified, then only these variables will be explained

Value

An object of the class surv_ceteris_paribus_explainer. It's a data frame with calculated average responses.

Examples

library(survxai) library(rms)
#> Ładowanie wymaganego pakietu: Hmisc
#> Ładowanie wymaganego pakietu: lattice
#> Ładowanie wymaganego pakietu: survival
#> Ładowanie wymaganego pakietu: Formula
#> Ładowanie wymaganego pakietu: ggplot2
#> #> Dołączanie pakietu: 'Hmisc'
#> Następujące obiekty zostały zakryte z 'package:base': #> #> format.pval, units
#> Ładowanie wymaganego pakietu: SparseM
#> #> Dołączanie pakietu: 'SparseM'
#> Następujący obiekt został zakryty z 'package:base': #> #> backsolve
data("pbcTrain") data("pbcTest") predict_times <- function(model, data, times){ prob <- rms::survest(model, data, times = times)$surv return(prob) } cph_model <- cph(Surv(years, status)~., data = pbcTrain, surv = TRUE, x = TRUE, y=TRUE) surve_cph <- explain(model = cph_model, data = pbcTest[,-c(1,5)], y = Surv(pbcTest$years, pbcTest$status), predict_function = predict_times) cp_cph <- ceteris_paribus(surve_cph, pbcTest[1,-c(1,5)])