unit8co / darts

A python library for user-friendly forecasting and anomaly detection on time series.
https://unit8co.github.io/darts/
Apache License 2.0
7.96k stars 866 forks source link

Does Darts support mixed-frequency data? #2451

Closed kkckk1110 closed 1 month ago

kkckk1110 commented 3 months ago

I have a dataset, in which the target time series is monthly recorded, while the covariates are daily recorded. In this, can I directly use the covariates to predict the target variable? I noticed that in 00-quickstart.ipynb, in the following codes, the past_covariates air_covs had both month and year records. But I still hope to check this issue. Thank you.

model = NBEATSModel(input_chunk_length=24, output_chunk_length=12, random_state=42)

model.fit( [train_air_scaled, train_milk_scaled], past_covariates=[air_covs, milk_covs], epochs=50, verbose=True, );

kkckk1110 commented 3 months ago

When I tried to achieve the purpose, I came across the following error:

ValueError: The dataset contains past covariates whose time axis doesn't allow to obtain the input (or output) chunk relative to the target series.

The past covariates are daily frequent while the target is monthly.

madtoinou commented 3 months ago

Hi @kkckk1110,

In the quick-start notebook, the two series have a monthly frequencies. However, if you are training your model with multiple target series, they don't need to all have the same frequencies. It's just important to make sure that each pair of target and covariates series have the same frequency (otherwise, it's not possible to "align them" and extract the lags).

In your case, you might want to use the MIDAS method to resample the past covariates.

Hope that it helps.

dennisbader commented 3 months ago

Just as a side note. Since not all months have the same number of days, using MIDAS will end up giving you some missing values for the last days of some of the months.