Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
notuntoward opened this issue Feb 24, 2023 · 9 comments
Open

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

notuntoward opened this issue Feb 24, 2023 · 9 comments

Comments

@notuntoward
Copy link

notuntoward commented Feb 24, 2023

When I run this:

boruta.fit(Xtrn, yTrn)

I get the error message below, indicating that boruta_py isn't compatible with numpy versions greater than 1.20. I had numpy version 1.24.2 installed. So I ran:

conda install "numpy<1.20"

and then I no longer got this error from Boruta. However, reverting to numpy<1.20 cost at least an hour of redoing my configuration of other packages.

A fix for this problem would be very helpful.

The error message


AttributeError Traceback (most recent call last)
File :7

File ~/miniconda3/envs/vder2022/lib/python3.9/site-packages/boruta/boruta_py.py:201, in BorutaPy.fit(self, X, y)
188 def fit(self, X, y):
189 """
190 Fits the Boruta feature selection with the provided estimator.
191
(...)
198 The target values.
199 """
--> 201 return self._fit(X, y)

File ~/miniconda3/envs/vder2022/lib/python3.9/site-packages/boruta/boruta_py.py:260, in BorutaPy._fit(self, X, y)
255 _iter = 1
256 # holds the decision about each feature:
257 # 0 - default state = tentative in original code
258 # 1 - accepted in original code
259 # -1 - rejected in original code
--> 260 dec_reg = np.zeros(n_feat, dtype=np.int)
261 # counts how many times a given feature was more important than
262 # the best of the shadow features
263 hit_reg = np.zeros(n_feat, dtype=np.int)
...

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

@the-holsti
Copy link

I had the same problem. I do not know if it helps you @notuntoward but I succesfully used BorutaPy with numpy==1.23.5.
(numpy.int was removed in 1.24.0)

@notuntoward
Copy link
Author

@the-holsti , that's good to know. Thanks. But hopefully, boruta_py will catch up soon, so that it remains viable into the future.

@cluttered-cabinet
Copy link

I was able to solve this by patching boruta_py.py and changing np.int -> int, np.float -> float, and np.bool -> bool, with the current version of NumPy

@notuntoward
Copy link
Author

@cluttered-cabinet thanks for that info. It might make sense to put up a pull request with your changes, but checking the existing PRs, it looks like this package isn't maintained.

One of the PRs mentions ARFS as an alternative. I'm going to give it a try.

@cluttered-cabinet
Copy link

@notuntoward I'm debating on doing the same...seems like ARFS does have good docs and it's up to date :)

@3zhang
Copy link

3zhang commented Apr 28, 2023

It is already patched here. It is not patched on pypi. So replace boruta_py.py with the file on github should solve the issue.

@luizhdramos
Copy link

Just replace np.int, np.float and np.bool for int, floar and bool on Boruta boruta_py.py

@aroyphillips
Copy link

Will this be patched on pypi?

@albarsil
Copy link

Waiting this change on pypi 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants