Boruta fit error

Hi,

I am trying to learn boruta by following the tutorial:

When I did

boruta.fit(np.array(X_train), np.array(y_train))

I got the following errors:
Traceback (most recent call last):
File “<pyshell#24>”, line 1, in
boruta.fit(np.array(X_train), np.array(y_train))
File “C:\Users\chaom02\AppData\Local\Programs\Python\Python311\Lib\site-packages\boruta\boruta_py.py”, line 201, in fit
return self._fit(X, y)
File “C:\Users\chaom02\AppData\Local\Programs\Python\Python311\Lib\site-packages\boruta\boruta_py.py”, line 260, in fit
dec_reg = np.zeros(n_feat, dtype=np.int)
File "C:\Users\chaom02\AppData\Local\Programs\Python\Python311\Lib\site-packages\numpy_init
.py", line 305, in getattr
raise AttributeError(former_attrs[attr])
NumPy 1.20.0 Release Notes — NumPy v1.25.dev0 Manual. Did you mean: ‘inf’?

I am using Python version 3.11.2. Can anyone please help me out? Many thanks.

Ming

I’d say the the error is up-stream from where your script errors out; either with the dataset or the estimator (maybe).

I’ve not done too much with ML and sklearn, so I can’t really advise more than that.

Consider asking about it in the comments section of that website, if know one here can help.

Thanks Rob for your prompt reply. I tested on different datasets and had the same errors. So it should not be related to the dataset. The estimator is a standard random forest and I do not see any issues with it. The errors pointed to two places and both are related to np.array:

Traceback (most recent call last):
File “<pyshell#41>”, line 1, in
boruta.fit(np.array(X_train), np.array(y_train))
File “C:\Users\chaom02\AppData\Local\Programs\Python\Python311\Lib\site-packages\boruta\boruta_py.py”, line 201, in fit
return self._fit(X, y)
^^^^^^^^^^^^^^^
File “C:\Users\chaom02\AppData\Local\Programs\Python\Python311\Lib\site-packages\boruta\boruta_py.py”, line 260, in fit
dec_reg = np.zeros(n_feat, dtype=np.int)
^^^^^^^^^
File "C:\Users\chaom02\AppData\Local\Programs\Python\Python311\Lib\site-packages\numpy_init
.py", line 305, in getattr
raise AttributeError(former_attrs[attr])
NumPy 1.20.0 Release Notes — NumPy v1.25.dev0 Manual. Did you mean: ‘inf’?

So I wonder if numpy (my version is 1.24.2) could be a problem?

Thanks,
Ming

I hear what you are saying, but it seems unlikely (to me) that NumPy (in and of itself) would be the root of the error.

Maybe you could break apart the boruta.fit(np.array(X_train), np.array(y_train)) code line to make sure that np.array(X_train) and np.array(y_train) are both returning valid arrays and that the .fit() method is able to take the said arrays as its arguments. As with any fault finding task, it’s a process of elimination.

I downgraded python from 3.11.2 to 3.10.0 and numpy from 1.24.2 to 1.23.1 and now everything works fine. Update the status in case other users need this info.

1 Like