eli5
eli5 copied to clipboard
formatting html
I'm having trouble formatting the html of a prediction explanation
Here is the code I'm using:
doc = '...'
te = TextExplainer(n_samples=200)
te.fit(doc, predict_proba)
explanation = te.explain_prediction()
html = format_as_html(explanation)
path = os.path.abspath('prediction.html')
url = 'file://' + path
with open(path, 'w') as f:
f.write(html)
webbrowser.open(url)
Two issues I'm having with this:
-
only a table of words and weights are shown. I want to show the original text paragraph with the words highlighted. How is this done?
-
how do I change the colors? I see
format_html_styles()
in the docs but it's not clear to me how this should be used...
For 1), this is likely caused by the fact that you are using a sckit-learn version >= 0.22 which is not compatible with ELI5, as explained here: https://github.com/TeamHG-Memex/eli5/issues/361. The issue seems very simple to fix but nobody has submitted a PR yet.
Therefore, I recommend that you use sckit-learn==0.21.3 until this is fixed.
Is there another fix? I downgraded and even created a new virtual environment, but still see only weights and no highlighted tex.
Now it should work. I tested it locally and on Google Colab and the examples from the documentation worked. I used the latest version, 0.11.0.