facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
https://facebook.github.io/prophet
MIT License
18.55k stars 4.54k forks source link

AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.. Did you mean: 'float16'? #2595

Closed jianboy closed 1 month ago

jianboy commented 4 months ago
    from prophet import Prophet
  File "/opt/python/3.12.1/lib/python3.12/site-packages/prophet/__init__.py", line 7, in <module>
    from prophet.forecaster import Prophet
  File "/opt/python/3.12.1/lib/python3.12/site-packages/prophet/forecaster.py", line 28, in <module>
    class Prophet(object):
  File "/opt/python/3.12.1/lib/python3.12/site-packages/prophet/forecaster.py", line 459, in Prophet
    ) -> NDArray[np.float_]:
                 ^^^^^^^^^
  File "/opt/python/3.12.1/lib/python3.12/site-packages/numpy/__init__.py", line 397, in __getattr__
    raise AttributeError(
AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.. Did you mean: 'float16'?

can not import prophet

version:

Requirement already satisfied: prophet in /opt/python/3.12.1/lib/python3.12/site-packages (1.1.5)
Requirement already satisfied: pandas in /opt/python/3.12.1/lib/python3.12/site-packages (2.2.2)
Requirement already satisfied: numpy in /opt/python/3.12.1/lib/python3.12/site-packages (2.0.0)
mrogocki commented 4 months ago

Hello,

I solved this issue for myself to replace the np.float_ with the suggestes np.float64 instead.

File prophet/forecaster.py @staticmethod def fourier_series( dates: pd.Series, period: Union[int, float], series_order: int, ) -> NDArray[~~np.float_~~ -> np.float64]: It would be then necessary to add numpy>=2.0.X in the requirements. Would this solve #2595?

mrogocki commented 4 months ago

Also duplicate with #2588 in my opinion :)

nizarhaider commented 4 months ago

@mrogocki yeah changing it in the forecaster.py fixed it for now.

Thanks.

kjdeveloper8 commented 3 months ago

adding this before importing prophet works for me

import numpy as np
np.float_ = np.float64
from prophet import Prophet
mindtd commented 3 months ago

@kjdeveloper8 order really matters!

import numpy as np from prophet import Prophet np.float = np.float64 # AttributeError: `np.floatwas removed in the NumPy 2.0 release. Usenp.float64` instead.

Thank you so much.

adding this before importing prophet works for me

import numpy as np
np.float_ = np.float64
from prophet import Prophet
tisba commented 2 months ago

Fixed in https://github.com/facebook/prophet/pull/2592