Pertinent negatives
In this section, we will visualize the contrastive explanation for a pertinent negative.
For example, the number 3 could be an 8 with a missing half:
Figure 10.13: 3 is half of 8!
We first display a specific instance:
# @title Generate contrastive explanation with pertinent negative
# Explained instance
idx = 15
X = x_test[idx].reshape((1,) + x_test[idx].shape)
plt.imshow(X.reshape(28, 28));
The output is displayed as follows
Figure 10.14: An instance to explain
We now check the accuracy of the model:
# @title Model prediction
cnn.predict(X).argmax(), cnn.predict(X).max()
We can see that the prediction is correct:
(5, 0.9988611)
We will now create a pertinent negative explanation.
CEM parameters
We will now set the parameters of the CEM explainer.
The Alibi notebook explains each parameter in detail.
I formatted the code in the following text so that each line of code is preceded by the description...