
Interpretability Deep Dive: Explainable AI
Understanding Feature Attributions, Integrated Gradients, and XRAI. How to satisfy regulatory constraints on 'Black Box' models.
Explainable AI (XAI) Methods
We introduced XAI briefly. Now we go deep into the Methods, as the exam asks you to pick the right one for the model type.
1. Feature Attribution Methods
Vertex AI Explainable AI supports three main algorithms based on the Shapley Values concept.
| Method | Best For | Logic |
|---|---|---|
| Sampled Shapley | Tabular (Trees, Ensembles) | Tests every combination of features to see marginal contribution. Computationally expensive but mathematically exact. |
| Integrated Gradients | Differentiable (Neural Networks) | Calculates the gradient of the prediction output with respect to the input features along a path from a baseline (black image) to the input. |
| XRAI | Images | Combines Integrated Gradients with Region Growing. It highlights regions (e.g., the dog's head) rather than scattered pixels. |
2. Choosing a Baseline
Integrated Gradients requires a Baseline. This is "what the model sees when there is no data."
- Images: A black image (all zeros).
- Text: Empty string or PAD tokens.
- Tabular: The median value of the training set.
Exam Trap: If your baseline is chosen poorly (e.g., a white image for a model trained on snow scenes), the explanations will be garbage.
3. Configuring XAI Metadata
To enable explanations on a Custom Model container, you must upload explanation_metadata.json.
This maps the "Input Tensor Name" (e.g., input_1:0) to the "Feature Name" (e.g., Age).
{
"inputs": {
"my_input_tensor": {
"input_tensor_name": "input_layer:0",
"encoding": "IDENTITY",
"modality": "numeric"
}
},
"outputs": {
"my_output_tensor": {
"output_tensor_name": "dense_2:0"
}
}
}
Knowledge Check
?Knowledge Check
You are deploying an image classification model to detect defects in steel pipes. The users (engineers) want to know WHICH PART of the pipe the model thinks is defective. Which XAI method provides the most human-readable visualization?