timeshap icon indicating copy to clipboard operation
timeshap copied to clipboard

Import Error: cannot import name 'Kernel'

Open ViniMelloeMuller opened this issue 2 years ago • 4 comments

Hello, i'm working on a project using timeSHAP (timeshap==1.0.4) and i'm getting ImportError when:

from timeshap.explainer import local_report

It says:

ImportError: cannot import name 'Kernel' from 'shap.explainers._kernel'

My shap version is (shap==0.43.0). Thanks in advance

ViniMelloeMuller avatar Oct 19 '23 13:10 ViniMelloeMuller

had the same issue. had to downgrade the shap version (e.g. 0.37.0)

OverGreenWaters avatar Oct 24 '23 14:10 OverGreenWaters

Looks like Kernel got recently renamed to KernelExplainer, https://github.com/shap/shap/commit/ca08229b8bb93ae05311532b7cc84f21ea8a8043#diff-7ac25c0cf4216cbad9d7079e83c9c36fea1de8413f8fc7460d1b32af21d1fbc2R38

I've renamed it in timeshap in these 2 places and it seems to work:

  • https://github.com/feedzai/timeshap/blob/main/src/timeshap/explainer/kernel/timeshap_kernel.py#L53
  • https://github.com/feedzai/timeshap/blob/main/src/timeshap/explainer/kernel/timeshap_kernel.py#L60

kevduc avatar Nov 22 '23 18:11 kevduc

Looks like Kernel got recently renamed to KernelExplainer, shap/shap@ca08229#diff-7ac25c0cf4216cbad9d7079e83c9c36fea1de8413f8fc7460d1b32af21d1fbc2R38

I've renamed it in timeshap in these 2 places and it seems to work:

  • https://github.com/feedzai/timeshap/blob/main/src/timeshap/explainer/kernel/timeshap_kernel.py#L53
  • https://github.com/feedzai/timeshap/blob/main/src/timeshap/explainer/kernel/timeshap_kernel.py#L60

Same issue.

Even after changing the Kernel name in timeshap_kernel.py to KernelExplainer as suggested, the problem persists. Is there any update or further guidance available?

drorhunvural avatar Aug 20 '24 17:08 drorhunvural

Maybe the merge was not pushed? The code still has 'Kernel' instead of 'KernelExplainer'

Corkman99 avatar Sep 06 '24 12:09 Corkman99