Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

01_getting_started_complete #1237

Closed
kgboyko opened this issue Jan 2, 2025 · 1 comment
Closed

01_getting_started_complete #1237

kgboyko opened this issue Jan 2, 2025 · 1 comment

Comments

@kgboyko
Copy link

kgboyko commented Jan 2, 2025

Description

Description

Block:

nf = NeuralForecast(
models=[
AutoNHITS(h=48, config=config_nhits, loss=MQLoss(), num_samples=5),
AutoLSTM(h=48, config=config_lstm, loss=MQLoss(), num_samples=2),
],
#freq='H',
)
nf.fit(df=Y_df)

Required replace freq='H' on freq=1

There is a tax block in another place, but with cross_validation:

nf = NeuralForecast(
models=[
AutoNHITS(h=48, config=config_nhits, loss=MQLoss(), num_samples=5),
AutoLSTM(h=48, config=config_lstm, loss=MQLoss(), num_samples=2),
],
freq='H',
)
cv_df = nf.cross_validation(Y_df, n_windows=2)

Likewise replace on freq=1.


ValueError Traceback (most recent call last)
Cell In[39], line 11
1 #%%capture
2 nf1 = NeuralForecast(
3 models=[
4 AutoNHITS(h=48, config=config_nhits, loss=MQLoss(), num_samples=5),
(...)
8 #freq=1, # https://pandas-pydata-org.translate.goog/pandas-docs/stable/user_guide/timeseries.html?_x_tr_sl=en&_x_tr_tl=ru&_x_tr_hl=ru&_x_tr_pto=sc#offset-aliases
9 )
---> 11 nf1.fit(df=Y_df)

File /opt/conda/lib/python3.10/site-packages/neuralforecast/core.py:495, in NeuralForecast.fit(self, df, static_df, val_size, sort_df, use_init_models, verbose, id_col, time_col, target_col, distributed_config, prediction_intervals)
493 # Process and save new dataset (in self)
494 if isinstance(df, (pd.DataFrame, pl_DataFrame)):
--> 495 validate_freq(df[time_col], self.freq)
496 self.dataset, self.uids, self.last_dates, self.ds = self._prepare_fit(
497 df=df,
498 static_df=static_df,
(...)
503 target_col=target_col,
504 )
505 self.sort_df = sort_df

File /opt/conda/lib/python3.10/site-packages/utilsforecast/validation.py:140, in validate_freq(times, freq)
135 def validate_freq(
136 times: Series,
137 freq: Union[str, int],
138 ) -> None:
139 if _is_int_dtype(times) and not isinstance(freq, int):
--> 140 raise ValueError(
141 "Time column contains integers but the specified frequency is not an integer. "
142 "Please provide a valid integer, e.g. freq=1"
143 )
144 if _is_dt_dtype(times) and isinstance(freq, int):
145 raise ValueError(
146 "Time column contains timestamps but the specified frequency is an integer. "
147 "Please provide a valid pandas or polars offset, e.g. freq='D' or freq='1d'."
148 )

ValueError: Time column contains integers but the specified frequency is not an integer. Please provide a valid integer, e.g. freq=1

Link

No response

Link

No response

@jmoralez
Copy link
Member

jmoralez commented Jan 2, 2025

Fixed by 2.0 release

@jmoralez jmoralez closed this as completed Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants