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

Add lightgbm treeSHAP support #16

Closed
wants to merge 6 commits into from
Closed

Add lightgbm treeSHAP support #16

wants to merge 6 commits into from

Conversation

mayer79
Copy link
Contributor

@mayer79 mayer79 commented Dec 18, 2020

Hello

I added a draft for supporting LightGBM's internal TreeSHAP algo, solving #15

Example

library(fastshap)
library(ggplot2)
library(xgboost)
library(lightgbm)

mod_xgb = xgb.train(
  params = list(objective = "reg:squarederror"),
  data = xgb.DMatrix(data.matrix(iris[, -1]), label = iris[[1]]),
  nrounds = 10,
  verbose = -2
)

mod_lgb = lgb.train(
  params = list(objective = "regression"),
  data = lgb.Dataset(data.matrix(iris[, -1]), label = iris[[1]]),
  nrounds = 10,
  verbose = -2
)

shap_xgb <- explain(mod_xgb, exact = TRUE, X = data.matrix(iris[, -1]))
autoplot(shap_xgb)

shap_lgb <- explain(mod_lgb, exact = TRUE, X = data.matrix(iris[, -1]))
autoplot(shap_lgb)

Let me know if something feels odd please.

@mayer79
Copy link
Contributor Author

mayer79 commented Feb 22, 2021

@bgreenwell : hello Brandon, should I retry to push this LightGBM addon? (I don't think the CI fail is due to my change).

@bgreenwell
Copy link
Owner

@bgreenwell : hello Brandon, should I retry to push this LightGBM addon? (I don't think the CI fail is due to my change).

Hi @mayer79 not sure how I missed this PR. The fail is probably due Travis-CI no longer being supported. I’ll take a look at this PR in the next couple of days. Thanks a lot!! 🙏

@mayer79
Copy link
Contributor Author

mayer79 commented Feb 22, 2021

@bgreenwell : hello Brandon, should I retry to push this LightGBM addon? (I don't think the CI fail is due to my change).

Hi @mayer79 not sure how I missed this PR. The fail is probably due Travis-CI no longer being supported. I’ll take a look at this PR in the next couple of days. Thanks a lot!! 🙏

No problem at all :-). Thanks a lot for looking into this.

@bgreenwell
Copy link
Owner

Hey @mayer79, sorry for the inconvenience, but would you mind submitting a PR for this new version? If not, I can easily grab your changes and just throw them in manually. Whatever is easiest.

@mayer79
Copy link
Contributor Author

mayer79 commented Mar 2, 2021

Hey @mayer79, sorry for the inconvenience, but would you mind submitting a PR for this new version? If not, I can easily grab your changes and just throw them in manually. Whatever is easiest.

No issue at all! I repushed but there are some conflicts. As I don't have the permission to resolve them, we can do two things:

  1. You fix them.
  2. I update my fork with your changes and deal with the conflicts.

@bgreenwell
Copy link
Owner

@mayer79 I ended up just manually pulling in most of the changes and crediting your contribution in the NEWS file (hope that's OK); my git skills are questionable when it comes to merging with conflicts :/

Let me know if the new changes do not work on your end and thanks a bunch for this valuable contribution! (Always looking for help :)

@bgreenwell bgreenwell closed this Mar 2, 2021
@mayer79
Copy link
Contributor Author

mayer79 commented Mar 2, 2021

Perfect fine. Thanks for the extra work!

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

Successfully merging this pull request may close these issues.

2 participants