1

Here is the full error traceback:

    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

Any help would be great.

David
  • 39
  • 6
  • 1
    As far as I can see, this error is correct. numpy does not have a `float` type. Instead, it has `float16`, `float32`, and `float64`. This seems like an error in the `tpot` package. – John Gordon Jan 03 '23 at 05:38
  • okay. thanks I'll report it to the tpot dev team. – David Jan 03 '23 at 23:20

1 Answers1

1

This issue happens when using tpot with numpy 1.24. This version of numpy has removed type aliases, like np.float. This was already declared as deprecated since version 1.20, and now it has been removed.

The developers of tpot should modify their code to avoid this issue. But, as a solution for the time being you can avoid the issue by simply using a version of numpy <1.24

More info on this issue and how to fix this in your own code can be found here.

magomar
  • 1,038
  • 1
  • 12
  • 26
  • Thank you. I downgraded it to 1.22.4 and I think it worked because I got a different error this time lol – David Jan 11 '23 at 22:29
  • 1
    Good. By the way, I wrote you should use numpy<1.3, but I meant numpy<1.24, so you can use 1.23. I 've just edited my answer – magomar Jan 13 '23 at 07:26