rasbt / mlxtend

A library of extension and helper modules for Python's data analysis and machine learning libraries.
https://rasbt.github.io/mlxtend/
Other
4.82k stars 853 forks source link

`np.NINF` was removed in the NumPy 2.0 release. Use `-np.inf` instead #1100

Open tam-nguyenminh opened 1 week ago

tam-nguyenminh commented 1 week ago

Hello,

I got this error while trying to use SequentialFeatureSelector. Could you please help take a look in the underlying codes? Thanks a lot

sfs = SFS(LogisticRegression(), k_features=5, #number of features to select forward = True, #rolling forward selection floating=False, # No floating selection scoring='accuracy', verbose=5, cv=5 ).fit(X_train,y_train)


AttributeError Traceback (most recent call last) Cell In[214], line 8 1 sfs = SFS(LogisticRegression(), 2 k_features=5, #number of features to select 3 forward = True, #rolling forward selection 4 # floating=False, # No floating selection 5 scoring='accuracy', 6 verbose=5, 7 cv=5 ----> 8 ).fit(X_train,y_train)

File c:\Users\84393\miniconda3\envs\venv_ds\Lib\site-packages\mlxtend\feature_selection\sequential_feature_selector.py:650, in SequentialFeatureSelector.fit(self, X, y, groups, **fit_params) 648 else: 649 self.fitted = True # the completion of sequential selection process. --> 650 self.finalize_fit() 652 return self

File c:\Users\84393\miniconda3\envs\venv_ds\Lib\site-packages\mlxtend\feature_selection\sequential_feature_selector.py:655, in SequentialFeatureSelector.finalize_fit(self) 654 def finalize_fit(self): --> 655 max_score = np.NINF 656 for k in self.subsets_: 657 if ( 658 k >= self.min_k 659 and k <= self.max_k 660 and self.subsets_[k]["avg_score"] > max_score 661 ):

File c:\Users\84393\miniconda3\envs\venv_ds\Lib\site-packages\numpy__init.py:411, in getattr(attr) 408 raise AttributeError(__former_attrs[attr]) 410 if attr in expired_attributes__: --> [411](file:///C:/Users/84393/miniconda3/envs/venv_ds/Lib/site-packages/numpy/init.py:411) raise AttributeError( 412 f"np.{attr} was removed in the NumPy 2.0 release. " [413](file:///C:/Users/84393/miniconda3/envs/venv_ds/Lib/site-packages/numpy/init.py:413) f"{expired_attributes[attr]}" 414 ) [416](file:///C:/Users/84393/miniconda3/envs/venv_ds/Lib/site-packages/numpy/init.py:416) if attr == "chararray": 417 warnings.warn( [418](file:///C:/Users/84393/miniconda3/envs/venv_ds/Lib/site-packages/numpy/init.py:418) "np.chararray is deprecated and will be removed from " 419 "the main namespace in the future. Use an array with a string " [420](file:///C:/Users/84393/miniconda3/envs/venv_ds/Lib/site-packages/numpy/init__.py:420) "or bytes dtype instead.", DeprecationWarning, stacklevel=2)

AttributeError: np.NINF was removed in the NumPy 2.0 release. Use -np.inf instead.

Ontheroad123 commented 6 days ago

modofied 655 "max_score = np.NINF" to "max_score = np.inf"