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

Plotting Questions #10

Closed
BrianMiner opened this issue May 16, 2019 · 3 comments
Closed

Plotting Questions #10

BrianMiner opened this issue May 16, 2019 · 3 comments
Labels
question Further information is requested

Comments

@BrianMiner
Copy link

BrianMiner commented May 16, 2019

All-
I fit a model : ebm.fit(X,y). Then I am able to see overall feature importance running:

import plotly 
plotly.tools.set_credentials_file(username='XXX', api_key='123')
import plotly.plotly as plotly_py
ebm_global = ebm.explain_global()
plotly_py.iplot(ebm_global.visualize())

Question 1: Is there a way to see more than the default top features?

Then if we pass an index into visualize, we get the shape of the effect of that feature:

plotly_py.iplot(ebm_global.visualize(0))

I can see local explanations:

ebm_local = ebm.explain_local(X,y)
plotly_py.iplot(ebm_local.visualize(20))

QUESTION 2: IS it possible to get this data back and not plot it?

Question 3:

How does the above differ from show()? I have been unable to get this to work but it looks like the only difference is a drop down selector?

@interpret-ml
Copy link
Collaborator

Hi Brian,

Thanks for the questions! We'll work backwards through the questions as they're all related:

Question 3: How does the above differ from show()?

You're right, the only difference is the drop down -- it just makes it a little easier to find the features you're looking for. If you call show with a list (ex: show([explanation]) it will launch a dashboard to enable comparisons. What errors are you running into with the show method?

QUESTION 2: IS it possible to get this data back and not plot it?

Yes, you can. Every explanation object supports a .data() method, which returns the raw data used to generate the visualization. So in your example, you can call ebm_global.data() to get the overall feature importances, or ebm_global.data(1) to get the data for the graph in feature 1 (the same applies for ebm_local).

Question 1: Is there a way to see more than the default top features?

Right now, our built in "summary" visualization only includes the top features, but you can easily call ebm_global.data() to get the scores for every feature, then use any plotting library of your choice.

@BrianMiner
Copy link
Author

That's fantastic!

I wont stress much about the issues with show in my environment then.

Last plotting questions, any plans in the roadmap to generate the feature shape curves with a local value highlighted (a vertical line) as in the original Ga2M paper?

@interpret-ml
Copy link
Collaborator

interpret-ml commented May 16, 2019

We don't have plans to support this directly in the code right now, but you can manipulate the Plotly objects with a bit of code to add it in. Here's a quick example:

from plotly.offline import iplot, init_notebook_mode
init_notebook_mode()

ebm_global = ebm.explain_global(name='EBM')
instance = X_test[:1]
feature_index = 0 # Feature to visualize


feature_plot = ebm_global.visualize(feature_index)  # Plotly object
plot_data = ebm_global.data(feature_index)   # Raw data pre-visualization 

y_min = min(plot_data['scores'])
y_max = max(plot_data['scores'])

feature_plot['layout']['shapes'] = [{
    'type': 'line',
    'x0': instance.iloc[0][feature_index],   # Value of the feature for instance 0
    'y0': y_min,
    'x1': instance.iloc[0][feature_index],
    'y1': y_max,
    'line': {    # Customize the line
        'color': 'red',
        'width': 3,
        'dash': 'dot'
    }
}]

iplot(feature_plot)

which will produce this:

image

You can play around with the style and shape of the line quite a bit -- here's the documentation for the plotly shapes API: https://plot.ly/python/shapes/

@interpret-ml interpret-ml added the question Further information is requested label Jun 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

2 participants