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.36k stars 4.52k forks source link

Model fit behaves very differently between `datetime64[ns]` and `datetime64[ms]`. #2529

Open secondtom opened 11 months ago

secondtom commented 11 months ago

I was unknowingly passing a dtype of datetime64[ms] to prophet and getting a very poor fit. Converted back to datetime64[ns] and model fit behaved as expected. It might be worth adding a check to warn other users.

My approach to convert was: df['ds'] = pd.to_datetime(df['ds'].dt.strftime('%Y-%m-%d'))

gauravkumar37 commented 1 month ago

I don't know how many hours I wasted chasing down this tricky behavior. The worst part was there were no warnings and model fits fine also, the predictions are however very poor. My fix was:

pd.set_option("mode.copy_on_write", True)
df_group["ts"] = df_group["ts"].astype('datetime64[ns]')