Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------------------------
- AttributeError Traceback (most recent call last)
- AttributeError: 'Explanation' object has no attribute 'conjugate'
- The above exception was the direct cause of the following exception:
- TypeError Traceback (most recent call last)
- Cell In[9], line 7
- 1 #import shap
- 2
- 3 #explainer = shap.Explainer(model)
- 4 #shap_values = explainer(X_train)
- 5
- 6 # create a SHAP dependence plot for a specific feature
- ----> 7 shap.dependence_plot("iv_total", shap_values, X_train)
- 8 plt.show()
- File ~/Research/Libraries/miniforge3/envs/workspace-ds/lib/python3.10/site-packages/shap/plots/_scatter.py:568, in dependence_legacy(ind, shap_values, features, feature_names, display_features, interaction_index, color, axis_color, cmap, dot_size, x_jitter, alpha, title, xmin, xmax, ax, show, ymin, ymax)
- 566 if not hasattr(ind, "__len__"):
- 567 if interaction_index == "auto":
- --> 568 interaction_index = approximate_interactions(ind, shap_values, features)[0]
- 569 interaction_index = convert_name(interaction_index, shap_values, feature_names)
- 570 categorical_interaction = False
- File ~/Research/Libraries/miniforge3/envs/workspace-ds/lib/python3.10/site-packages/shap/utils/_general.py:143, in approximate_interactions(index, shap_values, X, feature_names)
- 141 if not (i == index or np.sum(np.abs(val_other)) < 1e-8):
- 142 for j in range(0, len(x), inc):
- --> 143 if np.std(val_other[j:j + inc]) > 0 and np.std(shap_ref[j:j + inc]) > 0:
- 144 v += abs(np.corrcoef(shap_ref[j:j + inc], val_other[j:j + inc])[0, 1])
- 145 val_v = v
- File <__array_function__ internals>:5, in std(*args, **kwargs)
- File ~/Research/Libraries/miniforge3/envs/workspace-ds/lib/python3.10/site-packages/numpy/core/fromnumeric.py:3581, in std(a, axis, dtype, out, ddof, keepdims, where)
- 3578 else:
- 3579 return std(axis=axis, dtype=dtype, out=out, ddof=ddof, **kwargs)
- -> 3581 return _methods._std(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
- 3582 **kwargs)
- File ~/Research/Libraries/miniforge3/envs/workspace-ds/lib/python3.10/site-packages/numpy/core/_methods.py:262, in _std(a, axis, dtype, out, ddof, keepdims, where)
- 260 def _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *,
- 261 where=True):
- --> 262 ret = _var(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
- 263 keepdims=keepdims, where=where)
- 265 if isinstance(ret, mu.ndarray):
- 266 ret = um.sqrt(ret, out=ret)
- File ~/Research/Libraries/miniforge3/envs/workspace-ds/lib/python3.10/site-packages/numpy/core/_methods.py:242, in _var(a, axis, dtype, out, ddof, keepdims, where)
- 238 x = um.add(xv[..., 0], xv[..., 1], out=x.real).real
- 239 # Most general case; includes handling object arrays containing imaginary
- 240 # numbers and complex types with non-native byteorder
- 241 else:
- --> 242 x = um.multiply(x, um.conjugate(x), out=x).real
- 244 ret = umr_sum(x, axis, dtype, out, keepdims=keepdims, where=where)
- 246 # Compute degrees of freedom and make sure it is not negative.
- TypeError: loop of ufunc does not support argument 0 of type Explanation which has no callable conjugate method
Advertisement
Add Comment
Please, Sign In to add comment