Nixtla / nixtla

TimeGPT-1: production ready pre-trained Time Series Foundation Model for forecasting and anomaly detection. Generative pretrained transformer for time series trained on over 100B data points. It's capable of accurately predicting various domains such as retail, electricity, finance, and IoT with just a few lines of code 🚀.
https://docs.nixtla.io
Other
1.91k stars 151 forks source link

How should you specify irregular timestamps in freq parameter #374

Closed dannydepequilt closed 1 week ago

dannydepequilt commented 1 month ago

I'd like to specify a frequency of Mon-Sat for my data.

The example jupyter notebook describes how to specify business days Mon-Fri, but not custom ranges. I followed the suggested link to the pandas documentation:

Remember, for business days, the frequency is 'B'. For other frequencies, you can refer to the pandas offset aliases documentation.

And attempted this:

from pandas.tseries.offsets import CustomBusinessDay
custom_bday = CustomBusinessDay(weekmask='Mon Tue Wed Thu Fri Sat')
df = pd.read_csv(data_file_path)
nixtla_client = NixtlaClient(api_key = NIXTLA_KEY)
forecast = nixtla_client.forecast(df, h=8, freq=custom_bday)

But got a type error:

File ".../lib/python3.10/site-packages/utilsforecast/preprocessing.py", line 156, in fill_gaps ends = _determine_bound(end, freq, times_by_id, "max") + delta TypeError: Concatenation operation is not implemented for NumPy arrays, use np.concatenate() instead. Please do not rely on this error; it may not be given on all Python implementations.

elephaint commented 1 month ago

Thanks for using TimeGPT. Unfortunately we don't support custom time frequencies, so at this moment you're limited to using built-in pandas frequencies listed here.

For your use case, you could try to resample to a daily frequency and fill the missing values for Sunday. The strategy for this depends on the data source, for example in the case of retail demand it might be that on Sunday the business is always closed, so the target value can be filled with zeros on Sunday. For other use cases, it might make sense to use an interpolation technique to fill the value. You can read about how to do this in this tutorial.

Hope this helps.

github-actions[bot] commented 1 week ago

This issue has been automatically closed because it has been awaiting a response for too long. When you have time to to work with the maintainers to resolve this issue, please post a new comment and it will be re-opened. If the issue has been locked for editing by the time you return to it, please open a new issue and reference this one.