File /opt/homebrew/Caskroom/miniforge/base/envs/torch/lib/python3.9/site-packages/shap/explainers/_kernel.py:190, in Kernel.shap_values(self, X, kwargs)
188 if self.keep_index:
189 data = convert_to_instance_with_index(data, column_name, index_value[i:i + 1], index_name)
--> 190 explanations.append(self.explain(data, kwargs))
191 if kwargs.get("gc_collect", False):
192 gc.collect()
File /opt/homebrew/Caskroom/miniforge/base/envs/torch/lib/python3.9/site-packages/shap/explainers/_kernel.py:277, in Kernel.explain(self, incoming_instance, *kwargs)
274 self.allocate()
276 # weight the different subset sizes
--> 277 num_subset_sizes = np.int(np.ceil((self.M - 1) / 2.0))
278 num_paired_subset_sizes = np.int(np.floor((self.M - 1) / 2.0))
279 weight_vector = np.array([(self.M - 1.0) / (i (self.M - i)) for i in range(1, num_subset_sizes + 1)])
File /opt/homebrew/Caskroom/miniforge/base/envs/torch/lib/python3.9/site-packages/numpy/init.py:305, in getattr(attr)
300 warnings.warn(
301 f"In the future np.{attr} will be defined as the "
302 "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
304 if attr in former_attrs:
--> 305 raise AttributeError(former_attrs[attr])
307 # Importing Tester requires importing all of UnitTest which is not a
308 # cheap import Since it is mainly used in test suits, we lazy import it
309 # here to save on the order of 10 ms of import time for most users
310 #
311 # The previous way Tester was imported also had a side effect of adding
312 # the full numpy.testing namespace
313 if attr == 'testing':
AttributeError: module 'numpy' has no attribute 'int'.
np.int was a deprecated alias for the builtin int. To avoid this error in existing code, use int by itself. Doing this will not modify any behavior and is safe. When replacing np.int, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
I explored further and identified the issue lay in the shape library.
updating to the new release 0.42.0 should resolve the problem (it has in my local environment)
Description
When using the explainer module "kernel_shap", explainer.plot()
How to Reproduce
Expected Behavior
The code runs as expected for the tutorial lab 5
System Information
I have confirmed this occurs on google colab and my coda environment (which successfully runs auto prognosis)
Additional Context
AttributeError Traceback (most recent call last) Cell In[21], line 10 1 # Explain using Kernel SHAP 2 explainer = Explainers().get( 3 "kernel_shap", 4 model, (...) 8 task_type="classification", 9 ) ---> 10 explainer.plot(X.sample(frac=0.1))
File /opt/homebrew/Caskroom/miniforge/base/envs/torch/lib/python3.9/site-packages/autoprognosis/plugins/explainers/plugin_kernel_shap.py:124, in KernelSHAPPlugin.plot(self, X) 123 def plot(self, X: pd.DataFrame) -> None: # type: ignore --> 124 shap_values = self.explainer.shap_values(X) 125 shap.summary_plot(shap_values, X)
File /opt/homebrew/Caskroom/miniforge/base/envs/torch/lib/python3.9/site-packages/shap/explainers/_kernel.py:190, in Kernel.shap_values(self, X, kwargs) 188 if self.keep_index: 189 data = convert_to_instance_with_index(data, column_name, index_value[i:i + 1], index_name) --> 190 explanations.append(self.explain(data, kwargs)) 191 if kwargs.get("gc_collect", False): 192 gc.collect()
File /opt/homebrew/Caskroom/miniforge/base/envs/torch/lib/python3.9/site-packages/shap/explainers/_kernel.py:277, in Kernel.explain(self, incoming_instance, *kwargs) 274 self.allocate() 276 # weight the different subset sizes --> 277 num_subset_sizes = np.int(np.ceil((self.M - 1) / 2.0)) 278 num_paired_subset_sizes = np.int(np.floor((self.M - 1) / 2.0)) 279 weight_vector = np.array([(self.M - 1.0) / (i (self.M - i)) for i in range(1, num_subset_sizes + 1)])
File /opt/homebrew/Caskroom/miniforge/base/envs/torch/lib/python3.9/site-packages/numpy/init.py:305, in getattr(attr) 300 warnings.warn( 301 f"In the future
np.{attr}
will be defined as the " 302 "corresponding NumPy scalar.", FutureWarning, stacklevel=2) 304 if attr in former_attrs: --> 305 raise AttributeError(former_attrs[attr]) 307 # Importing Tester requires importing all of UnitTest which is not a 308 # cheap import Since it is mainly used in test suits, we lazy import it 309 # here to save on the order of 10 ms of import time for most users 310 # 311 # The previous way Tester was imported also had a side effect of adding 312 # the fullnumpy.testing
namespace 313 if attr == 'testing':AttributeError: module 'numpy' has no attribute 'int'.
np.int
was a deprecated alias for the builtinint
. To avoid this error in existing code, useint
by itself. Doing this will not modify any behavior and is safe. When replacingnp.int
, you may wish to use e.g.np.int64
ornp.int32
to specify the precision. If you wish to review your current use, check the release note link for additional information. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations