Calculate the GradSHAP values of the Survival Function
surv_gradSHAP.Rd
This function calculates the GradSHAP values of the survival function with respect to the input features and time points for a given instance. In the paper, this is referred to as the "GradSHAP(t)" method. It is a fast and model-specific method for calculating the Shapley values for a deep survival model.
Usage
surv_gradSHAP(
exp,
target = "survival",
instance = 1,
times_input = TRUE,
batch_size = 1000,
n = 50,
num_samples = 10,
data_ref = NULL,
dtype = "float",
replace = TRUE,
include_time = FALSE
)
# S3 method for class 'explainer_deepsurv'
surv_gradSHAP(
exp,
target = "survival",
instance = 1,
times_input = TRUE,
batch_size = 1000,
n = 50,
num_samples = 10,
data_ref = NULL,
dtype = "float",
replace = TRUE,
...
)
# S3 method for class 'explainer_coxtime'
surv_gradSHAP(
exp,
target = "survival",
instance = 1,
times_input = TRUE,
batch_size = 1000,
n = 50,
num_samples = 10,
data_ref = NULL,
dtype = "float",
replace = TRUE,
include_time = FALSE
)
# S3 method for class 'explainer_deephit'
surv_gradSHAP(
exp,
target = "survival",
instance = 1,
times_input = TRUE,
batch_size = 1000,
n = 50,
num_samples = 10,
data_ref = NULL,
dtype = "float",
replace = TRUE,
...
)
Arguments
- exp
An object of class
explainer_deepsurv
,explainer_coxtime
, orexplainer_deephit
.- target
A character string indicating the target output. For
DeepSurv
andCoxTime
, it can be either"survival"
(default),"cum_hazard"
, or"hazard"
. ForDeepHit
, it can be"survival"
(default),"cif"
, or"pmf"
.- instance
An integer specifying the instance for which the GradSHAP values are calculated. It should be between 1 and the number of instances in the dataset.
- times_input
A logical value indicating whether the GradSHAP values should be multiplied with input.
- batch_size
An integer specifying the batch size for processing. The default is 1000. This value describes the number of instances within one batch and not the final number of rows in the batch. For example,
CoxTime
replicates each instance for each time point.- n
An integer specifying the number of samples to be used for approximating the integral. The default is 50.
- num_samples
An integer specifying the number of samples to be used for the baseline distribution. The default is 10.
- data_ref
A reference dataset for sampling. If
NULL
, the reference dataset is taken from the input data of the model. This dataset should contain the same number of features as the input data.- dtype
A character string indicating the data type for the tensors. It can be either
"float"
(default) or"double"
.- replace
A logical value indicating whether to sample from the baseline distribution with replacement. The default is
TRUE
.- include_time
A logical value indicating whether to calculate GradSHAP also for each time point. This is only relevant for
CoxTime
and is ignored forDeepSurv
andDeepHit
. The default isFALSE
.- ...
Unused arguments.
#' @return Returns an object of class
surv_result
.
See also
Other Attribution Methods:
surv_grad()
,
surv_intgrad()
,
surv_smoothgrad()