Issue
When displaying summary_plot, the color bar does not show.
shap.summary_plot(shap_values, X_train)
I have tried changing plot_size. When the plot is higher the color bar appears, but it is very small - doesn't look like it should.
shap.summary_plot(shap_values, X_train, plot_size=0.7)
Here is an example of a proper looking color bar.
Does anyone know if this can be fixed somehow?
How to reproduce:
import pandas as pd
import shap
import sklearn
from sklearn.ensemble import RandomForestRegressor
# a classic housing price dataset
X,y = shap.datasets.boston()
# a simple linear model
model = RandomForestRegressor(max_depth=6, random_state=0, n_estimators=10)
model.fit(X, y)
shap_values = shap.TreeExplainer(model).shap_values(X)
shap.summary_plot(shap_values, X)
In this case, the color bar is displayed, but it is very small. I have chosen such an example to make it easy to retrieve the data.
Solution
I had the same problem as you did, and I found that the solution was to downgrade matplotlib to 3.4.3.. It appears SHAP isn't optimized for matplotlib 3.5.1 yet.
Answered By - ethan tenison
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.