marcotcr / lime

Lime: Explaining the predictions of any machine learning classifier
BSD 2-Clause "Simplified" License
11.42k stars 1.79k forks source link

show_in_notebook() flips positive/negative values when labels or top_labels is specified #633

Closed kennysong closed 2 years ago

kennysong commented 2 years ago

show_in_notebook() seems to have a bug if the explanation is generated for a "0" label rather than a "1".

What the explanation should look like:

Screen Shot 2021-08-08 at 4 54 01 PM

What it looks like if you specify labels=[0] or top_labels=1 in explain_instance():

Screen Shot 2021-08-08 at 4 54 44 PM

Here's a Colab notebook to reproduce, based on the tutorial notebook Lime - basic usage, two class case.ipynb.

marcotcr commented 2 years ago

This is indeed a bug, due to a hack I added to the javascript where I assume that if you have binary classification you'd always want to see the same plot with label 0 on the left and label 1 on the right. I think I just won't fix it, as I think that is a fair assumption and people should just use labels=(1,) if they're doing binary classification (I should document it though).

Thanks!!