Skip to content

Conversation

@teabolt
Copy link
Contributor

@teabolt teabolt commented Jul 17, 2019

Based on #315 and #329, we use Grad-CAM to highlight parts of text that contribute to a prediction of a Keras classifier.

For example, we can use a call similar to this:

eli5.show_prediction(model, doc, 
        tokens=doc_tokens,
        pad_x=word_index['<PAD>'],
        padding='post',
        relu=False,
)

To roughly highlight positive and negative parts of a text (explaining the score given in sentiment analysis):
Screenshot from 2019-07-17 18-13-25

This PR also makes refactorings (including changes to the public API) to the code at the linked PR's.

WIP items:

  • Tutorial.
  • Pass CI and coverage.
  • Tests (manual and automated).
  • Docs.
  • Mypy.

teabolt and others added 30 commits July 1, 2019 16:19
@teabolt
Copy link
Contributor Author

teabolt commented Sep 10, 2019

@lopuhin Do you think there is anything major left to do in this PR? (besides making the CI pass)

@lopuhin
Copy link
Contributor

lopuhin commented Sep 17, 2019

@teabolt I don't recall anything significant, and from a quick glance it looks like all review feedback is addressed so I think it's almost ready.

@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2020

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 98.26990% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.34%. Comparing base (017c738) to head (347ed35).

Files with missing lines Patch % Lines
eli5/nn/text.py 96.00% 2 Missing and 2 partials ⚠️
eli5/formatters/image.py 95.83% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #325      +/-   ##
==========================================
+ Coverage   97.32%   97.34%   +0.02%     
==========================================
  Files          49       52       +3     
  Lines        3142     3320     +178     
  Branches      585      623      +38     
==========================================
+ Hits         3058     3232     +174     
- Misses         44       46       +2     
- Partials       40       42       +2     
Files with missing lines Coverage Δ
eli5/base.py 100.00% <100.00%> (ø)
eli5/ipython.py 100.00% <ø> (ø)
eli5/keras/__init__.py 100.00% <100.00%> (ø)
eli5/keras/explain_prediction.py 98.37% <100.00%> (+1.98%) ⬆️
eli5/keras/gradcam.py 100.00% <100.00%> (ø)
eli5/nn/__init__.py 100.00% <100.00%> (ø)
eli5/nn/gradcam.py 100.00% <100.00%> (ø)
eli5/formatters/image.py 98.71% <95.83%> (-1.29%) ⬇️
eli5/nn/text.py 96.00% <96.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@teabolt teabolt force-pushed the keras-gradcam-text branch from ec0f51c to 6e960ff Compare June 6, 2020 13:53
Copy link
Contributor

@lopuhin lopuhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @teabolt I hope I can finish review in a week, looks really solid, left a few minor comments

@Hellisotherpeople
Copy link

Is this ever going to be merged? I'm super interested in seeing this get added to ELI5 ASAP!!!

@teabolt
Copy link
Contributor Author

teabolt commented Jan 11, 2021

Is this ever going to be merged? I'm super interested in seeing this get added to ELI5 ASAP!!!

Hey @Hellisotherpeople . Sorry for the late reply. If you are still interested you can try installing the PR branch directly with pip:

  1. If you are using virtualenv or a similar environment manager, make a clone of your environment.
  2. Install the PR branch with pip install -U git+https://github.com/teabolt/eli5.git@keras-gradcam-text

To test that it worked run:

import eli5.keras
eli5.keras.explain_prediction_keras_text()

The output should be TypeError: explain_prediction_keras_text() missing 2 required positional arguments: 'model' and 'doc'

Tested this with Python 3.7 and Ubuntu 20.04.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants