Stack Exchange
I have a python error for numpy implementation for a shapley value model
I want to insert this code into my python
import random
import warnings
import numpy as np
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline

warnings.filterwarnings("ignore")

And the  error is:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-6c2b9bf4cfd2> in <module>
      2 import warnings
      3 import numpy as np
----> 4 from sklearn.datasets import load_breast_cancer
      5 from sklearn.model_selection import train_test_split
      6 from sklearn.preprocessing import StandardScaler

~/opt/anaconda3/lib/python3.8/site-packages/sklearn/datasets/__init__.py in <module>
     20 from ._lfw import fetch_lfw_pairs
     21 from ._lfw import fetch_lfw_people
---> 22 from ._twenty_newsgroups import fetch_20newsgroups
     23 from ._twenty_newsgroups import fetch_20newsgroups_vectorized
     24 from ._openml import fetch_openml

~/opt/anaconda3/lib/python3.8/site-packages/sklearn/datasets/_twenty_newsgroups.py in <module>
     43 from ._base import _fetch_remote
     44 from ._base import RemoteFileMetadata
---> 45 from ..feature_extraction.text import CountVectorizer
     46 from .. import preprocessing
     47 from ..utils import check_random_state, Bunch

~/opt/anaconda3/lib/python3.8/site-packages/sklearn/feature_extraction/__init__.py in <module>
      7 from ._dict_vectorizer import DictVectorizer
      8 from ._hash import FeatureHasher
----> 9 from .image import img_to_graph, grid_to_graph
     10 from . import text
     11 

~/opt/anaconda3/lib/python3.8/site-packages/sklearn/feature_extraction/image.py in <module>
    170 @_deprecate_positional_args
    171 def grid_to_graph(n_x, n_y, n_z=1, *, mask=None, return_as=sparse.coo_matrix,
--> 172                   dtype=np.int):
    173     """Graph of the pixel-to-pixel connections
    174 

~/opt/anaconda3/lib/python3.8/site-packages/numpy/__init__.py in __getattr__(attr)
    303 
    304         if attr in __former_attrs__:
--> 305             raise AttributeError(__former_attrs__[attr])
    306 
    307         # Importing Tester requires importing all of UnitTest which is not a

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 have installed numpy new as it looks like there is a problem as I understood with all these "int" within numpy.
but it doesnt resolve the problem it is still the same problem.
Does anybody has a idea how i can resolve this problem? Or maybe somebody has experience with the same problem for shapley value models.

Does this answer your question? Got many error from "sklearn" Python library

Your sklearn and numpy versions are incompatible (see error message all the way at the bottom). A quick fix would be to downgrade numpy to 1.19.5.
pip install --force-reinstall numpy==1.19.5

Better would be to upgrade both packages as suggested in this question, as Python 3.8 is still activately supported.
pip install scikit-learn numpy --upgrade

