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

BUG: waterfall color customisation #3293

Closed
4 tasks done
surbhi-gupta-drishya opened this issue Sep 29, 2023 · 3 comments
Closed
4 tasks done

BUG: waterfall color customisation #3293

surbhi-gupta-drishya opened this issue Sep 29, 2023 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behaviour

Comments

@surbhi-gupta-drishya
Copy link

surbhi-gupta-drishya commented Sep 29, 2023

Issue Description

This issue is same as raised in here
With default waterfall function, we are unable to change the color of waterfall plot.
With this implementation all the existing functions will work "as is" with the enhancement of color customization. With this, the users of shap library can change the waterfall plot color as per their wish/requirement.
Earlier they can see waterfall plot in Red and Blue color only:
image

Minimal Reproducible Example

import pandas as pd
import numpy as np
import lightgbm as lgbm
import shap
temp = pd.DataFrame(np.random.randint(10,100,(100,10)),columns=["x_"+str(i) for i in range(10)])
temp["y"] = np.sum(temp.iloc[:,:8],axis=1) - np.sum(temp.iloc[:,8:],axis=1)

model = lgbm.LGBMRegressor(n_estimators=2, learning_rate=0.1)
X, y =temp.drop(["y"],axis=1), temp[["y"]]
model.fit(X,y )

explainer = shap.TreeExplainer(model)
idx=70
pred = model.predict(X.iloc[idx:idx+1])
shap_values = explainer(X.iloc[idx:idx+1])

shap.plots.waterfall(shap_values[0], max_display=10, show=False)

Traceback

No response

Expected Behavior

Color of water fall as defined by user.

Bug report checklist

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest release of shap.
  • I have confirmed this bug exists on the master branch of shap.
  • I'd be interested in making a PR to fix this bug

Installed Versions

'0.42.1'

@surbhi-gupta-drishya surbhi-gupta-drishya added the bug Indicates an unexpected problem or unintended behaviour label Sep 29, 2023
@qzpthuhhu
Copy link

Do you know how to save the images generated by shap.plots.bar or shap.plots.waterfall locally and control the format or dpi?

@surbhi-gupta-drishya
Copy link
Author

Yes

@qzpthuhhu
Copy link

Thanks for your reply. My problem has been solved by setting show=False and then plotting it myself.

是的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behaviour
Projects
None yet
Development

No branches or pull requests

2 participants