TeamHG-Memex / eli5

A library for debugging/inspecting machine learning classifiers and explaining their predictions
http://eli5.readthedocs.io
MIT License
2.76k stars 334 forks source link

formatting html #388

Open peterbayerle opened 4 years ago

peterbayerle commented 4 years ago

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

Bougeant commented 4 years ago

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.

jonas-nothnagel commented 3 years ago

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

Querela commented 3 years ago

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.