eli5 icon indicating copy to clipboard operation
eli5 copied to clipboard

Allow batch explanations for Keras classifiers

Open teabolt opened this issue 5 years ago • 1 comments

The explain_prediction function for keras classifiers (https://github.com/TeamHG-Memex/eli5/pull/315, https://github.com/TeamHG-Memex/eli5/pull/329) accepts a doc argument. Currently doc must have the shape (1, dims...) (batch size equal to 1).

It would be good to be able to take tensors with any batch size, and explain each image in the batch.

This would make it convenient for the user to check many samples without the need for loops, etc. For example, the user may pass to ELI5 a batch containing all the images / texts that were misclassified.

Re: implementation. Expressions like value = value[0] or value, = value (getting the first sample from the batch) would need to be replaced.

teabolt avatar Jun 26 '19 14:06 teabolt

It would be also cool to add batched explanations for text (https://github.com/TeamHG-Memex/eli5/pull/325).

This would include:

  • Taking the eli5.nn.text module and making all functions/operations be able to take batched data.
  • Removing the _unbatch_tokens work-around function from eli5.keras.explain_prediction module.

In the Explanation's themselves we could just add multiple TargetExplanation's to targets. format_as_html should be able to handle this. However, changes would be needed to format_as_image.

teabolt avatar Aug 17 '19 17:08 teabolt