Description Usage Arguments Value Examples
View source: R/ceteris_paribus.R
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.
1 2 3 4 5 6 | ceteris_paribus(
explainer,
observation,
grid_points = 5,
selected_variables = NULL
)
|
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 |
An object of the class surv_ceteris_paribus_explainer. It's a data frame with calculated average responses.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | library(survxai)
library(rms)
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)~ sex + bili + stage,
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)])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.