EpistasisLab / tpot

A Python Automated Machine Learning tool that optimizes machine learning pipelines using genetic programming.
http://epistasislab.github.io/tpot/
GNU Lesser General Public License v3.0
9.75k stars 1.57k forks source link

Error using TPOT with numpy >= 1.24.0 (or fresh TPOT installs) #1281

Open chimaerase opened 1 year ago

chimaerase commented 1 year ago

Context of the issue

Newer releases of Numpy (and by extension, fresh installs of TPOT) are not compatible with the latest TPOT code and requirements.txt. Several deprecated numpy aliases are removed in Numpy 1.24.0, and at least one (numpy.float) is still used in the TPOT code.

Process to reproduce the issue

  1. Install TPOT in a fresh Python environment (virtualenv) pip install -r requirements.txt
  2. Run the Python shell and import tpot
    python
    >>> import tpot
  3. TPOT raises AttributeError
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/Users/mark.forrer/Documents/code/tpot/tpot/__init__.py", line 27, in <module>
    from .tpot import TPOTClassifier, TPOTRegressor
    File "/Users/mark.forrer/Documents/code/tpot/tpot/tpot.py", line 31, in <module>
    from .base import TPOTBase
    File "/Users/mark.forrer/Documents/code/tpot/tpot/base.py", line 71, in <module>
    from .builtins import CombineDFs, StackingEstimator
    File "/Users/mark.forrer/Documents/code/tpot/tpot/builtins/__init__.py", line 29, in <module>
    from .one_hot_encoder import OneHotEncoder, auto_select_categorical_features, _transform_selected
    File "/Users/mark.forrer/Documents/code/tpot/tpot/builtins/one_hot_encoder.py", line 136, in <module>
    class OneHotEncoder(BaseEstimator, TransformerMixin):
    File "/Users/mark.forrer/Documents/code/tpot/tpot/builtins/one_hot_encoder.py", line 216, in OneHotEncoder
    def __init__(self, categorical_features='auto', dtype=np.float,
    File "/Users/mark.forrer/.pyenv/versions/tpot/lib/python3.8/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
    AttributeError: module 'numpy' has no attribute 'float'

Expected result

Successful TPOT import

Current result

AtttributeError on TPOT import

Possible fix

Document the requirement for numpy <1.24.0 until the TPOT code can be updated

notwopr commented 1 year ago

i've received this error as well, and I have all my dependencies up to date.

Traceback (most recent call last): File "C:\Users\david\github\beluga3\SCRATCHPAPER_6.py", line 4, in <module> from MLModule.AI.featuretoolstpot.ml_framework import MyMLModeler File "C:\Users\david\github\beluga3\MLModule\AI\featuretoolstpot\ml_framework.py", line 8, in <module> from tpot import TPOTClassifier File "C:\Users\david\AppData\Local\Programs\Python\Python310\lib\site-packages\tpot\__init__.py", line 27, in <module> from .tpot import TPOTClassifier, TPOTRegressor File "C:\Users\david\AppData\Local\Programs\Python\Python310\lib\site-packages\tpot\tpot.py", line 31, in <module> from .base import TPOTBase File "C:\Users\david\AppData\Local\Programs\Python\Python310\lib\site-packages\tpot\base.py", line 70, in <module> from .builtins import CombineDFs, StackingEstimator File "C:\Users\david\AppData\Local\Programs\Python\Python310\lib\site-packages\tpot\builtins\__init__.py", line 29, in <module> from .one_hot_encoder import OneHotEncoder, auto_select_categorical_features, _transform_selected File "C:\Users\david\AppData\Local\Programs\Python\Python310\lib\site-packages\tpot\builtins\one_hot_encoder.py", line 136, in <module> class OneHotEncoder(BaseEstimator, TransformerMixin): File "C:\Users\david\AppData\Local\Programs\Python\Python310\lib\site-packages\tpot\builtins\one_hot_encoder.py", line 216, in OneHotEncoder def __init__(self, categorical_features='auto', dtype=np.float, File "C:\Users\david\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\__init__.py", line 284, in __getattr__ raise AttributeError("module {!r} has no attribute " AttributeError: module 'numpy' has no attribute 'float'. Did you mean: 'cfloat'?

As you can see, when it tries to instantiate the class OneHotEncoder, the class has one input parameter of dtype, and it uses np.float. But apparently numpy has no such attribute. I checked all my dependencies, and made sure everything was upgrade.

I'm running Python 3.10.2

chimaerase commented 1 year ago

@notwopr, looks like repo permissions prevent me from linking this issue to the associated PR (#1282), but I verified the fix there just by updating the NumPY requirement.

sarahyurick commented 1 year ago

Fixed since https://github.com/EpistasisLab/tpot/pull/1280 has been merged.

I recommend using pip install git+ to ensure that you're installing with these changes.

charlesbluca commented 1 year ago

cc @weixuanfu with #1280 merged in, would it be possible to cut a new release of tpot?