Enhancing explainability via text generation
In this recipe, we will learn how to understand the inference emitted by the classifier using text generation. We will use the same classifier that we used in the Explainability via a classifier invariant approach recipe. To better understand the behavior of the classifier in a random setting, we will replace the words in the input sentence with different tokens.
Getting ready
We will need to install a spacy
artifact for this recipe. Please use the following command in your environment before starting this recipe.
Now that we have installed spacy
, we will need to download the en_core_web_sm
pipeline using the following step beforehand:
python3 -m spacy download en_core_web_sm
You can use the 9.8_explanability_via_generation.ipynb
notebook from the code site if you need to work from an existing notebook.
How to do it
Let’s get started:
- Do the necessary imports:
import numpy as np import spacy import time...