lime
lime copied to clipboard
Deprecation Warning for Ipython
I see this error when running show_in_notebook():
/opt/miniconda3/lib/python3.9/site-packages/lime/explanation.py:194:
DeprecationWarning: Importing display from
IPython.core.display is deprecated since IPython 7.14,
please import from IPython display
from IPython.core.display import display, HTML
Appears to be coming from line 194 explanation.py
This also prevents the table from rendering!
With the release of IPython 9, this now breaks.
>>> from IPython.core.display import display
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'display' from 'IPython.core.display' (/Users/petergedeck/git/mlba-python-notebooks/.venv/lib/python3.12/site-packages/IPython/core/display.py)
With IPython 8, the error message is:
>>> from IPython.core.display import display
<stdin>:1: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython.display
It's trivial to fix
def show_in_notebook(self,
labels=None,
predict_proba=True,
show_predicted_value=True,
**kwargs):
"""Shows html explanation in ipython notebook.
See as_html() for parameters.
This will throw an error if you don't have IPython installed"""
from IPython.display import display, HTML
display(HTML(self.as_html(labels=labels,
predict_proba=predict_proba,
show_predicted_value=show_predicted_value,
**kwargs)))
A trivial workaround may be to just call
display(HTML(exp.as_html()))
instead of
exp.show_in_notebook()