Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KernelShap] ZeroDivisionError: Weights sum to zero, can't be normalized #4

Open
nfelnlp opened this issue May 2, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@nfelnlp
Copy link
Member

nfelnlp commented May 2, 2021

KernelShap is not working yet and gave the following error:

Traceback (most recent call last):
  File "/home/nfel/PycharmProjects/thermostat/venv/lib/python3.8/site-packages/captum/attr/_core/lime.py", line 484, in attribute
    self.interpretable_model.fit(DataLoader(dataset, batch_size=n_samples))
  File "/home/nfel/PycharmProjects/thermostat/venv/lib/python3.8/site-packages/captum/_utils/models/linear_model/model.py", line 303, in fit
    return super().fit(train_data=train_data, **kwargs)
  File "/home/nfel/PycharmProjects/thermostat/venv/lib/python3.8/site-packages/captum/_utils/models/linear_model/model.py", line 260, in fit
    return super().fit(
  File "/home/nfel/PycharmProjects/thermostat/venv/lib/python3.8/site-packages/captum/_utils/models/linear_model/model.py", line 117, in fit
    return self.train_fn(
  File "/home/nfel/PycharmProjects/thermostat/venv/lib/python3.8/site-packages/captum/_utils/models/linear_model/train.py", line 329, in sklearn_train_linear_model
    sklearn_model.fit(x, y, sample_weight=w, **fit_kwargs)
  File "/home/nfel/PycharmProjects/thermostat/venv/lib/python3.8/site-packages/sklearn/linear_model/_base.py", line 525, in fit
    X, y, X_offset, y_offset, X_scale = self._preprocess_data(
  File "/home/nfel/PycharmProjects/thermostat/venv/lib/python3.8/site-packages/sklearn/linear_model/_base.py", line 162, in _preprocess_data
    X_offset = np.average(X, axis=0, weights=sample_weight)
  File "<__array_function__ internals>", line 5, in average
  File "/home/nfel/PycharmProjects/thermostat/venv/lib/python3.8/site-packages/numpy/lib/function_base.py", line 409, in average
    raise ZeroDivisionError(
ZeroDivisionError: Weights sum to zero, can't be normalized
@nfelnlp nfelnlp added the bug Something isn't working label May 2, 2021
@nfelnlp nfelnlp self-assigned this May 2, 2021
nfelnlp added a commit that referenced this issue May 2, 2021
@nfelnlp nfelnlp changed the title ZeroDivisionError: Weights sum to zero, can't be normalized [KernelShap] ZeroDivisionError: Weights sum to zero, can't be normalized May 2, 2021
@nfelnlp
Copy link
Member Author

nfelnlp commented May 12, 2021

Not an easy fix after discussing it briefly with @rbtsbg .
Will not implement KernelShap for the first version/publication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant