报错内容:
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
最近学习鸢尾花分类的案例,其中一步报错,如上所示
原因:
新的版本里面没有np.int了
解决办法:
1、降低版本:
pip uninstall numpy
pip install numpy==1.19.0
2、修改源码:
y=(iris['target']==2).astype(np.int) #修改前
y=(iris['target']==2).astype(int) #修改后
为了防止低版本的numpy影响其他库,我选择了第二种方法,结果如下可以正常运行