Anil Kumar
Anil Kumar

Reputation: 445

SHAP Summary plot for LIghtGBM

How to explain below shap summary plot for each class. I have checked below document for the explanation still is not very clear to me. Please explain.

https://shap.readthedocs.io/en/latest/example_notebooks/tabular_examples/tree_based_models/Census%20income%20classification%20with%20LightGBM.html

enter image description here

Upvotes: 0

Views: 2890

Answers (2)

Abhineet Gupta
Abhineet Gupta

Reputation: 629

A late answer, but for lgbm classifier, the shap_values obtained from shap.TreeExplainer() are a list of len = number of classes. So for a binary case, it's a list of 2 arrays, where one array is the negative of the other (as expected). As a result, plotting it as is does not provide a lot of information as the bars of each class for a feature are equal in length.

To get more information from the shap summary plot, use the index associated with your class of interest (e.g., 1 for positive class).

Code example for binary classification -

shap_values = shap.TreeExplainer(lgbm_model.shap_values(x_test))
len(shap_values) == 2
shap.summary_plot(shap_values[1], x_test)

Upvotes: 1

Arpit Sisodia
Arpit Sisodia

Reputation: 649

'Relationship' is most important variable for classifying both the class as width is maximum for both- blue and red.

For any variable, lets say age if blue part is more than red, we can say variable is more important to identify class 0, compare to class 1. In your case all variables seems like there is no such property.

Upvotes: -1

Related Questions