Hello, im trying to predict 24h of a target, using...
# neural-forecast
g
Hello, im trying to predict 24h of a target, using different models. However im getting this error --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[36], <vscode-notebook-cell:?execution_count=36&line=1|line 1> ----> <vscode-notebook-cell:?execution_count=36&line=1|1> Y_hat_df = nf.predict(time_col='Time_data', target_col = 'SUD', verbose=True) <vscode-notebook-cell:?execution_count=36&line=2|2> Y_hat_df = Y_hat_df.reset_index() <vscode-notebook-cell:?execution_count=36&line=3|3> Y_hat_df.head() File ~/.local/lib/python3.10/site-packages/neuralforecast/core.py:723, in NeuralForecast.predict(self, df, static_df, futr_df, sort_df, verbose, engine, **data_kwargs) 720 cols = self._get_model_names() 722 # Placeholder dataframe for predictions with unique_id and ds --> 723 fcsts_df = ufp.make_future_dataframe( 724 uids=uids, 725 last_times=last_dates, 726 freq=self.freq, 727 h=self.h, 728 id_col=self.id_col, 729 time_col=self.time_col, 730 ) 732 # Update and define new forecasting dataset 733 if futr_df is None: File ~/.local/lib/python3.10/site-packages/utilsforecast/processing.py:594, in make_future_dataframe(uids, last_times, freq, h, id_col, time_col) 589 else: 590 df_constructor = pd.DataFrame 591 return df_constructor( 592 { 593 id_col: repeat(uids, h), --> 594 time_col: time_ranges(starts, freq=freq, periods=h), 595 } 596 ) File ~/.local/lib/python3.10/site-packages/utilsforecast/processing.py:420, in time_ranges(starts, freq, periods) 418 out = np.vstack(out).ravel(order="F") 419 else: --> 420 raise ValueError( *421 f"`starts` must be integers or timestamps, got '{*starts_dtype}'." 422 ) 423 out = pd.Series(out) 424 else: ValueError:
starts
must be integers or timestamps, got '<class 'pandas._libs.tslibs.timestamps.Timestamp'>'. my dataframe is composed by three columns, unique_id, Time_data (ds) and SUD (y) Time_data is already time stamp df.index is a simply RangeIndex(start=0, stop=51673, step=1 Can anyone help me?
m
Hello! Can you try using
<http://pd.to|pd.to>_datetime
on the Time_data column?
j
If your timestamps have timezone can you try upgrading utilsforecast (
pip install - U utilsforecast
)
g
Thanks for your replies. @Marco Yes, it was already a datetime64[ns,UTC] type. Upgrading utils didnt' work, I solved removing the localize (by applying tz.localize(None) and with some modifies on time zone. Thanks!!
j
I realized I wrote the command wrong, it should be
pip install -U utilsforecast
(no space after the dash) which would install 0.1.10 and that should work with time zones. Can you please confirm if you got that version (
pip show utilsforecast
)?
g
@José Morales yes, I wrote it without the space, but still it didn't work. However I decided to use crossvalidation, that did work fine also with time zones (I have other question about that function, but I will keep it for the next days 😂)
j
Hmm, your error looked exactly like this issue. If you're able to reproduce it with utilsforecast 0.1.10 could you share your code so that I can find the problem?