I have been trying to work with the shap
package. I want to determine the shap values from my logistic regression model. Contrary to the TreeExplainer
, the LinearExplainer
requires a so-called masker. What exactly does this masker do and what is the difference between the independent and partition maskers?
Also, I am interested in the important features from the test-set. Do I then fit the masker on the training set or the test set? Below you can see a snippet of code.
model = LogisticRegression(random_state = 1)
model.fit(X_train, y_train)
masker = shap.maskers.Independent(data = X_train)
**or**
masker = shap.maskers.Independent(data = X_test)
explainer = shap.LinearExplainer(model, masker = masker)
shap_val = explainer(X_test)```