timeshap
timeshap copied to clipboard
Import Error: cannot import name 'Kernel'
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
had the same issue. had to downgrade the shap version (e.g. 0.37.0)
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
Looks like
Kernelgot recently renamed toKernelExplainer, shap/shap@ca08229#diff-7ac25c0cf4216cbad9d7079e83c9c36fea1de8413f8fc7460d1b32af21d1fbc2R38I've renamed it in
timeshapin 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?
Maybe the merge was not pushed? The code still has 'Kernel' instead of 'KernelExplainer'