Since all methods and the preceding conversion step in the innsight
package were implemented using R6 classes and these always require a call
to classname$new() for initialization, the following functions are
defined to shorten the construction of the corresponding R6 objects:
convert() for Converter
run_grad() for Gradient
run_smoothgrad() for SmoothGrad
run_intgrad() for IntegratedGradient
run_expgrad() for ExpectedGradient
run_lrp() for LRP
run_deeplift() for DeepLift
run_deepshap for DeepSHAP
run_cw for ConnectionWeights
run_lime for LIME
run_shap for SHAP
# Create a new `Converter` object of the given `model`
convert(model, ...)
# Apply the `Gradient` method to the passed `data` to be explained
run_grad(converter, data, ...)
# Apply the `SmoothGrad` method to the passed `data` to be explained
run_smoothgrad(converter, data, ...)
# Apply the `IntegratedGradient` method to the passed `data` to be explained
run_intgrad(converter, data, ...)
# Apply the `ExpectedGradient` method to the passed `data` to be explained
run_expgrad(converter, data, ...)
# Apply the `LRP` method to the passed `data` to be explained
run_lrp(converter, data, ...)
# Apply the `DeepLift` method to the passed `data` to be explained
run_deeplift(converter, data, ...)
# Apply the `DeepSHAP` method to the passed `data` to be explained
run_deepshap(converter, data, ...)
# Apply the `ConnectionWeights` method (argument `data` is not always required)
run_cw(converter, ...)
# Apply the `LIME` method to explain `data` by using the dataset `data_ref`
run_lime(model, data, data_ref, ...)
# Apply the `SHAP` method to explain `data` by using the dataset `data_ref`
run_shap(model, data, data_ref, ...)(nn_sequential, keras_model,
neuralnet or list)
A trained neural network for classification or regression
tasks to be interpreted. Only models from the following types or
packages are allowed: nn_sequential,
keras_model,
keras_model_sequential,
neuralnet or a named list (see details).
Note: For the model-agnostic methods, an arbitrary fitted model for a
classification or regression task can be passed. A Converter object can
also be passed. In order for the package to know how to make predictions
with the given model, a prediction function must also be passed with
the argument pred_fun. However, for models created by
nn_sequential, keras_model,
neuralnet or Converter,
these have already been pre-implemented and do not need to be
specified.
Other arguments passed to the individual constructor functions of the methods R6 classes.
(Converter)
An instance of the Converter class that includes the
torch-converted model and some other model-specific attributes. See
Converter for details.
(array, data.frame, torch_tensor or list)
The data to which the method is to be applied. These must
have the same format as the input data of the passed model to the
converter object. This means either
an array, data.frame, torch_tensor or array-like format of
size (batch_size, dim_in), if e.g., the model has only one input layer, or
a list with the corresponding input data (according to the
upper point) for each of the input layers.
Note: For the model-agnostic methods, only models with a single
input and output layer is allowed!
(array, data.frame or torch_tensor)
The dataset to which the method is to be applied. These must
have the same format as the input data of the passed model and has to
be either matrix, an array, a data.frame or a
torch_tensor.
Note: For the model-agnostic methods, only models with a single
input and output layer is allowed!
R6::R6Class object of the respective type.