Visualization toolkit for ML and DL methods
- Support calculating SHAP values for scikit-learn decision tree regressor.
- Sample script to show how the result would look like.
- Clone or download this repository and go into the root of the toolkit.
- In your code, do as follows:
from SHAP.tree import TreeExplainer # model is your own sklearn.tree.DecisionTreeRegressor() # Predictors: labels of x explainer = TreeExplainer(model).shap_values(x=data[0]) print(explainer[0, :]) plt.bar(range(len(predictors)), explainer[0, :-1], tick_label=predictors)
- Clone or download this repository and go into the root of the toolkit.
- Run
$ python sample_script.tree.decision_tree_sample.py
Then you are likely to see a shap.png
in the pwd. The picture is a bar figure and should look like