interpretml / interpret

Fit interpretable models. Explain blackbox machine learning.
https://interpret.ml/docs
MIT License
6.27k stars 728 forks source link

2d PDP Z-axis colours appear too similar #535

Open emrynHofmannElephant opened 5 months ago

emrynHofmannElephant commented 5 months ago

Hi, not sure if this is always the case, or just when the interactions don't provide much value, but the colours within the explainability dashboard (and when you export them) are very flat. Perhaps instead of using the scores_range here, something else should be used?

https://github.com/interpretml/interpret/blob/bf111b59bf8acb9943d8763664b769573434ebdb/python/interpret-core/interpret/visual/plot.py#L654

At the moment I've fixed the issue within a function which exports the individual plots:

fig = model.explain_global().visualize(key)
# Reformat the plot - autoscale, and if it is a heatmap (2d PDP) rescale the Z value
fig["layout"]["yaxis"].update(autorange=True)
if hasattr(fig.data[0], "z"): # Checks if there's Z values 
    fig = fig.update_traces(
        zmin=np.min(fig.data[0].z)-(0.5*np.abs(np.min(fig.data[0].z))), # Set zmin as the min plotted, minus a little bit
        zmax=np.max(fig.data[0].z)+(0.5*np.abs(np.max(fig.data[0].z))), # Set zmax as the max plotted, plus a little bit
        selector=dict(type='heatmap') # Only apply this to heatmaps
    )

Where key is an iterator from a loop of indices

Before the change: image After: image

(not the best example, due to this pdp being quite flat, but even in the case of a 2x2 plot, it looked flat, but there is a difference between z values)

paulbkoch commented 5 months ago

Hi @emrynHofmannElephant -- I think the color scale could be improved by using the maximum absolute score of the pairs instead of the existing scores_range. We have a previous issue for this. The underlying problem is that the EBM visualizations use the maximum absolute score for both pairs and mains, but often the pair score range is smaller than for the mains.

https://github.com/interpretml/interpret/issues/236