Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to graph without spinning a local web-server #52

Closed
jyipks opened this issue Aug 20, 2019 · 9 comments
Closed

how to graph without spinning a local web-server #52

jyipks opened this issue Aug 20, 2019 · 9 comments

Comments

@jyipks
Copy link

jyipks commented Aug 20, 2019

Is this API available yet? We cant seem to plot it locally with plotly offline.

Hi @dfrankow, thanks for the issue! We're just about to introduce a few new API changes that should make this easier in our next release. One, we'll let you specify a port in the show method, so that you can pick your own port that you know is open. Second, we'll introduce a new function that doesn't spin up the local web-server, and directly uses plotly to visualize it. For now, here are a few notes:

visualize() does return a plotly object, and you can use plotly.offline so that you don't need an api key. And yes, if you pass in a key to visualize() , you can get a specific graph back out!

If you run this code at the top of your notebook:

from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)

you can then use "iplot(plotly_figure)" in your notebook to get a direct plotly graph. We'll have a nicer API around this soon!

Originally posted by @interpret-ml in #1 (comment)

@interpret-ml
Copy link
Collaborator

interpret-ml commented Aug 21, 2019

Hi @jyipks - thanks for the issue,

There's two ways as mentioned. For the first where the web server needs to be spun up but at a specific address there's this:

from interpret import set_show_addr

set_show_addr(('127.0.0.1', 7001))

show(explanation)  # Will run on 127.0.0.1/localhost at port 7001

However if you don't want to spin up the web server at all, you won't get the dashboard but you can still plot the graphs with the preserve method as such:

# 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')

Currently preserve is a stop-gap measure, in the future we'll try to have the show method handle environments where it is either impossible or not agreeable to run a web server.

@yulonglin
Copy link

yulonglin commented Sep 2, 2019

Is it possible to retrieve the "Summary" page?

For example, without needing to specify column name:

preserve(ebm_global)

@yulonglin
Copy link

Just a note, preserve also allows locating via the index besides the column name. Especially useful for local interpretations

preserve(ebm_local, 0, file_name='example0.html')

@trungngv
Copy link

@interpret-ml has this issue been fixed yet?

@interpret-ml
Copy link
Collaborator

interpret-ml commented Nov 27, 2019

Hi @trungngv,

We do have a better workaround than the preserve method. If you run the following code at the top of your notebook:

from interpret.provider import InlineProvider
from interpret import set_visualize_provider

set_visualize_provider(InlineProvider())

Interpret will start rendering visualizations in Javascript, and embed them directly in the notebook (without needing to spin up a local server). You can then use the show method the exact same way as before. Ex:

ebm_global = ebm.explain_global()
show(ebm_global) # Works without a web server if set_visualize_provider() was run earlier

Please let us know if this works for you!

-InterpretML Team

@jyipks
Copy link
Author

jyipks commented Nov 27, 2019

I attempted this on version 0.1.19 and I got the following, am I missing something?
ModuleNotFoundError: No module named 'interpret.provider'

@interpret-ml
Copy link
Collaborator

Hi @jyipks,

That's interesting. Can you try the following?

pip uninstall interpret
pip uninstall interpret-core

and then run

pip install interpret

Effectively reinstalling the interpret library. We've seen this in rare cases where upgrading interpret from older versions can cause issues.

@trungngv
Copy link

trungngv commented Dec 2, 2019

@interpret-ml yes, thanks for the for quick fix. This is working for me now except a separate issue related to IOpub data rate, which seems to be due to dash. This stackoverflow question has the fix:
https://stackoverflow.com/questions/43288550/iopub-data-rate-exceeded-in-jupyter-notebook-when-viewing-image

@interpret-ml
Copy link
Collaborator

Hi @trungngv --

Great to hear it's working, and it looks like the other issue is resolved per the stackoverflow thread.

-InterpretML team

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

No branches or pull requests

4 participants