shap / shap

A game theoretic approach to explain the output of any machine learning model.
https://shap.readthedocs.io
MIT License
22.39k stars 3.24k forks source link

Can TreeExplainer be used with tf.estimator.BoostedTreesClassifier? #958

Closed shendiaomo closed 3 weeks ago

shendiaomo commented 4 years ago

I can't see BoostedTreesEstimator in the source code of TreeExplainer, but BoostedTreesEstimator is an important part of TensorFlow canned estimators and should be supported by TreeExplainer.

ThuongCroud commented 4 years ago

hi shendiaomo, I've tried using the TreeExplainer with Tensorflow's Boosted Trees Estimator before, but unfortunately it's not compatible. As a plan B, I ended up following this guide here to build something similar using LGBM instead: https://towardsdatascience.com/prediction-and-inference-with-boosted-trees-and-shapley-values-4ffef46b969a

It would be great if TreeExplainer was compatible with Tensorflow, though!

slundberg commented 4 years ago

I agree it would be great to support this directly. There is no fundamental reason we couldn't add these bindings, but the TF BoostedTreesEstimator is very tightly bound to the input formats of TF tensors so it might be a bit more work than some other sklearn models. (since the BoostedTreesEstimator does not just take in a standard dataframe by default).

Tagging this since I don't have the bandwidth to tackle it at the moment.

shendiaomo commented 4 years ago

hi shendiaomo, I've tried using the TreeExplainer with Tensorflow's Boosted Trees Estimator before, but unfortunately it's not compatible. As a plan B, I ended up following this guide here to build something similar using LGBM instead: https://towardsdatascience.com/prediction-and-inference-with-boosted-trees-and-shapley-values-4ffef46b969a

It would be great if TreeExplainer was compatible with Tensorflow, though!

At last, I managed to support explaining TF estimators using KernelExplainer, thanks to the discussion here and at https://github.com/slundberg/shap/issues/280.

Directly supporting BoostedTreesEstimator with TreeExplainer is still wanted because shap.TreeExplainer(model).shap_interaction_values(X) is rather useful.

zhangxiang390 commented 4 years ago

hi shendiaomo, I've tried using the TreeExplainer with Tensorflow's Boosted Trees Estimator before, but unfortunately it's not compatible. As a plan B, I ended up following this guide here to build something similar using LGBM instead: https://towardsdatascience.com/prediction-and-inference-with-boosted-trees-and-shapley-values-4ffef46b969a It would be great if TreeExplainer was compatible with Tensorflow, though!

At last, I managed to support explaining TF estimators using KernelExplainer, thanks to the discussion here and at #280.

Directly supporting BoostedTreesEstimator with TreeExplainer is still wanted because shap.TreeExplainer(model).shap_interaction_values(X) is rather useful.

hi, would you show me some demo code here how can use SHAP with tensorflow Estimator, Thanks a million.

bbakernoaa commented 2 years ago

I would also be interested in this

ShuyangenFrance commented 2 years ago

I am interested in this and I would like to see if I can contribute.

github-actions[bot] commented 3 months ago

This issue has been inactive for two years, so it's been automatically marked as 'stale'.

We value your input! If this issue is still relevant, please leave a comment below. This will remove the 'stale' label and keep it open.

If there's no activity in the next 90 days the issue will be closed.

github-actions[bot] commented 3 weeks ago

This issue has been automatically closed due to lack of recent activity.

Your input is important to us! Please feel free to open a new issue if the problem persists or becomes relevant again.