eli5 icon indicating copy to clipboard operation
eli5 copied to clipboard

formatting html

Open peterbayerle opened this issue 4 years ago • 3 comments

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:

  1. 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?

  2. 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...

peterbayerle avatar Aug 25 '20 19:08 peterbayerle

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.

Bougeant avatar Sep 05 '20 12:09 Bougeant

Is there another fix? I downgraded and even created a new virtual environment, but still see only weights and no highlighted tex.

jonas-nothnagel avatar Feb 05 '21 11:02 jonas-nothnagel

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.

Querela avatar Mar 02 '21 22:03 Querela