scikit-learn-contrib / DESlib

A Python library for dynamic classifier and ensemble selection
BSD 3-Clause "New" or "Revised" License
477 stars 106 forks source link

AttributeError: module 'numpy' has no attribute 'int'. #274

Closed NickWatsonMan closed 1 year ago

NickWatsonMan commented 1 year ago

I'm using DESlib and classification fails on BaseDCS class because the use of np.int is deprecated.

Traceback:

File /usr/local/lib/python3.11/site-packages/deslib/dcs/base.py:120, in BaseDCS.select(self, competences)
    118 diff = best_competence.reshape(-1, 1) - competences
    119 # TODO: Improve this part of the code
--> 120 selected_classifiers = np.zeros(diff.shape[0], dtype=np.int)
    121 for row in range(diff.shape[0]):
    122     diff_list = list(diff[row, :])

The text of the error:

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:
NickWatsonMan commented 1 year ago

The fast fix is to set somewhere in your code:

np.int = int
Menelau commented 1 year ago

@NickWatsonMan Hello,

Thanks for opening this issue. Indeed I need to make it compatible with the new bumpy version. I will push an update asap.

fraimondo commented 1 year ago

@Menelau: check the PR, that might be the solution.