Skip to content

Numpy "negative dimensions are not allowed" error in explanations.py (line 521) Β #5

@sushi15

Description

@sushi15

Hi Dylan!

I was running your code on a number of datapoints to calculate SHAP estimates using KernelSHAP and got "negative dimensions are not allowed" numpy error on a particular datapoint after which the code crashed. The error was raised at line 521 in explanations.py. I believe the error is because the value for n_needed for the particular datapoint came out to be lower than the value of ptg_inital_points which is set it to its default value of 200. This is not happening for all datapoints because the n_needed value caluclated each time is different of course, but adding an if-else statement to handle this edge case and bypass the second call to _shap_tabular_perturb_n_samples fixed it.

Regards
Suchismita

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions