Modeling-Uncertainty-Local-Explainability icon indicating copy to clipboard operation
Modeling-Uncertainty-Local-Explainability copied to clipboard

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

Open sushi15 opened this issue 3 years ago • 1 comments

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

sushi15 avatar Aug 30 '22 06:08 sushi15

Hey, thanks for catching this. I'll update soon to fix this case

dylan-slack avatar Aug 30 '22 06:08 dylan-slack