Closed anaquio closed 5 years ago
Hey @anaquio - thanks for reporting this!
Unfortunately that will happen (we have to document this better).
Method show(...)
has a server behind the scenes driving the visualizations you see, similar to TensorBoard. If you try to save the Jupyter notebook or open the notebook much later (after Jupyter has closed at some point), the error will appear.
Upon saying that, if you update to the latest version of interpret (v0.1.5), there's an alternative method that should save to your notebook without the need of a server running in the background. This method is called preserve
, and will work with most visualizations (only exception is decision trees).
# Replace show with the preserve.
ebm_global = ebm.explain_global(name='EBM')
# show(ebm_global)
from interpret import preserve
# preserve(ebm_global, 'Age', file_name='global-age-graph.html')
preserve(ebm_global, 'Age')
The method preserve
is different to show
, for instance you have to provide a key (such as 'Age' for a global explanation, or an integer index in the case of local). It won't have the same level of interactivity, but you will get to store the results in a notebook or in a separate file.
Hope this helps, let us know if you have any more questions/issues!
How am I supposed to use the index with local explanations?
I make it work with the following:
ebm_local = ebm.explain_local(X_test[:1], y_test[:1], name='EBM')
preserve(ebm_local, selector_key = ebm_local.selector[ebm_local.selector.columns[0]])
But I am not sure this will work in the general case.
Besides, with this new method, I am not getting the refused to connect error, but when I re-open the notebook I can't see the graph but a blank space... Any clue?
Hi @anaquio,
The selector_key
can either be an integer index that selects the i-th instance passed into explain_local
, otherwise it's used as a lookup into the first column of selector to find its respective instance. Make sure to be on the latest version (v0.1.7) - we had to patch the integer indexing.
ebm_local = ebm.explain_local(X_test[:5], y_test[:5], name='EBM') # Pass in the first 5 instances.
preserve(ebm_local, 3) # Of the 5 instances, get an explanation for instance at index 3.
If the plots don't show up in the notebook, try making sure your notebook is "trusted" (there's a button in the top right of the jupyter notebook). Here's a quick example:
Thank you very much, @interpret-ml. I am now trying to use Azure notebooks with interpret but I am getting the same error "127.0.0.1 refused to connect", the first time I try to plot an image, not when re-opening the Azure notebook again, any idea of why this could be happening?
By the way, the trusted mode did work to show the plots. Thanks.
Hi @anaquio,
The method show
will fail on Azure notebooks, but you should be able to use preserve
.
We have to wait on Azure notebooks to enable some features (jupyter-server-proxy or similar) in order for it to work.
Thanks for this library!
I have been able to run everything as it is following the README.md, However, when I re-open the Jupyter notebook I have been using, instead of the images created with the
show(hist)
,show(ebm_perf)
commands I am getting the following error: 127.0.0.1 refused to connect.I have read the different issues and some similar problem happened on #14, but I couldn't figure out how to fix the issue myself. The same happens if I download the jupyter notebook in .html format and I open it after closing the Jupyter notebook connection.
Can anyone throw some light on it?