Skip to content

Additivity check failed in TreeExplainer! (with check_additivity=False) #28

@mahboobctwd

Description

@mahboobctwd

Hi, I am trying to use the survshap library to extract SHAP values from a random survival model. I passed the training dataset to the SurvivalModelExplainer. The following code gives an idea:

rsf = RandomSurvivalForest(
    n_estimators=8, n_jobs=-1, random_state=random_state
)

rsf.fit(X_train, y_train)

explainer = SurvivalModelExplainer(model = rsf, data = X_train, y = y_train)
model_survshap = ModelSurvSHAP(calculation_method="treeshap") 
model_survshap.fit(explainer = explainer)

My X_train contains some one-hot encoded features and I'm getting the following error:

ExplainerError: Additivity check failed in TreeExplainer! Please ensure the data matrix you passed to the explainer is the same shape that the model was trained on. If your data shape is correct then please report this on GitHub. This check failed because for one of the samples the sum of the SHAP values was 0.666667, while the model output was 0.000000. If this difference is acceptable you can set check_additivity=False to disable this check.

I passed check_additivity=False which didn't change the outcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions