Saltar al contenido principal

OcclusionSaliency

LocalExplainer
DashAI.back.explainability.explainers.OcclusionSaliency

Perturbation-based saliency maps for image classifiers.

Slides a gray patch over the image and records how much the predicted class probability drops at each position. Regions whose occlusion causes a large drop are the ones the model relied on. Unlike Grad-CAM, this method needs no gradients or convolutional layers, so it works with every DashAI image classifier including the MLP; the trade-off is one model evaluation per patch position.

References

Parameters

patch_size : integer, default=16
Side (in pixels) of the square patch that is occluded at each position. Smaller patches give finer maps but require more model evaluations.
stride : integer, default=8
Step (in pixels) between consecutive patch positions. Smaller strides give smoother maps but require more model evaluations.

Methods

explain_instance(self, instances)

Defined on OcclusionSaliency

Compute an occlusion saliency map for each image.

Parameters

instances : DashAIDataset
Images to be explained; the first column must contain images.

Returns

dict
Dictionary with, for each image, the resized image, the saliency map and the model prediction.

fit(self, background_dataset, **kwargs)

Defined on OcclusionSaliency

Store class names in the model's class-index order.

Parameters

background_dataset : Tuple[DatasetDict, DatasetDict]
Tuple (x, y) with the dataset splits.
**kwargs : Any
Ignored; present for interface compatibility.

Returns

OcclusionSaliency
The fitted explainer instance (self).

plot(self, explanation: dict) -> List[DashAI.back.core.artifacts.GroupedArtifacts]

Defined on OcclusionSaliency

Render each image as a saliency overlay plus a text summary.

Parameters

explanation : dict
Dictionary with the explanation generated by the explainer.

Returns

List[GroupedArtifacts]
A single grouped artifact with one group per explained image, each holding that image's saliency overlay and text summary.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.

Parameters

raw_data : dict
A dictionary with the data provided by the user to initialize the model.

Returns

dict
A validated dictionary with the necessary objects.