Skip to contents

This function calculates the attributions of the model (Break Down, SHAP, or Oscillations explanations) for each observation in the raster. Model predictions are decomposed into parts that are attributed for particular variables, and then the attributions are assigned to the corresponding cells in the raster. See the documentation of the DALEX::predict_parts() function for more details.

Usage

predict_spatial_parts(
  explainer,
  raster_obs,
  maxcell = 1000,
  ...,
  N = if (substr(type, 1, 4) == "osci") 500 else NULL,
  type = "break_down"
)

Arguments

explainer

a model to be explained, preprocessed by the DALEX::explain() function

raster_obs

a raster object with the observations to be explained (predictors used in the model)

maxcell

the maximum number of cells in the raster. If the number of cells in the raster is greater than maxcell, the function will sample maxcell cells from the raster. By default 1000

...

other parameters that will be passed to iBreakDown::break_down()

N

the maximum number of observations used for calculation of attributions. By default NULL (use all) or 500 (for oscillations)

type

the type of variable attributions. Either shap, oscillations, oscillations_uni, oscillations_emp, break_down or break_down_interactions

Value

A raster object with the same dimensions as raster_obs. The number of layers equal to the number of variables in the model or the number of variables in the model plus one if type is not shap.

References

Lundberg, S. (2017). A unified approach to interpreting model predictions. arXiv preprint arXiv:1705.07874.

Staniak, M., & Biecek, P. (2018). Explanations of model predictions with live and breakDown packages. arXiv preprint arXiv:1804.01955.

Biecek, P., & Burzykowski, T. (2021). Explanatory model analysis: explore, explain, and examine predictive models. Chapman and Hall/CRC.

Examples

library(terra)
#> terra 1.7.83
predictors_agg = rast(system.file("raster/predictors_agg.tif", package = "spatialexplain"))
data("regr_exp", package = "spatialexplain")
regr_psp_bd = predict_spatial_parts(regr_exp, predictors_agg, maxcell = 100)
plot(regr_psp_bd)