Instance Level Parts of Survival Model Predictions
Instance Level Parts of Survival Model Predictions
This function decomposes the model prediction into individual parts, which are attributions of particular variables. The explanations can be made via the SurvLIME and SurvSHAP(t) methods.
predict_parts(explainer,...)## S3 method for class 'surv_explainer'predict_parts( explainer, new_observation,..., N =NULL, type ="survshap", output_type ="survival", explanation_label =NULL)
Arguments
explainer: an explainer object - model preprocessed by the explain() function
...: other parameters which are passed to iBreakDown::break_down if output_type=="risk", or if output_type=="survival" to surv_shap() or surv_lime() functions depending on the selected type
new_observation: a new observation for which prediction need to be explained
N: the number of observations used for calculation of attributions. If NULL (default) all explainer data will be used for SurvSHAP(t) and 100 neigbours for SurvLIME.
type: if output_type == "survival" must be either "survshap" or "survlime", otherwise refer to the DALEX::predict_parts
output_type: either "survival", "chf" or "risk" the type of survival model output that should be considered for explanations. If "survival" the explanations are based on the survival function. If "chf" the explanations are based on the cumulative hazard function. Otherwise the scalar risk predictions are used by the DALEX::predict_parts function.
explanation_label: a label that can overwrite explainer label (useful for multiple explanations for the same explainer/model)
Returns
An object of class "predict_parts_survival" and additional classes depending on the type of explanations. It is a list with the element result containing the results of the calculation.
Additional parameters
There are additional parameters that are passed to internal functions
for survlime
N - a positive integer, number of observations generated in the neighbourhood
distance_metric - character, name of the distance metric to be used, only "euclidean" is implemented
kernel_width - a numeric, parameter used for calculating weights, by default it's sqrt(ncol(data)*0.75)
sampling_method - character, name of the method of generating neighbourhood, only "gaussian" is implemented
sample_around_instance - logical, if the neighbourhood should be generated with the new observation as the center (default), or should the mean of the whole dataset be used as the center
max_iter - a numeric, maximal number of iteration for the optimization problem
categorical_variables - character vector, names of variables that should be treated as categories (factors are included by default)
k - a small positive number \> 1, added to chf before taking log, so that weigths aren't negative
for survshap
y_true - a two element numeric vector or matrix of one row and two columns, the first element being the true observed time and the second the status of the observation, used for plotting
calculation_method - a character, either "kernelshap" for use of kernelshap library (providing faster Kernel SHAP with refinements) or "exact_kernel" for exact Kernel SHAP estimation
aggregation_method - a character, either "mean_absolute" or "integral", "max_absolute", "sum_of_squares"