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.91k stars 858 forks source link

[Question] Forecasting (Multivariate or Multiple) TimeSeries with multiple covariates #2346

Closed ZhangAllen98 closed 2 months ago

ZhangAllen98 commented 4 months ago

In the multi-time-series example, Note that ElectricityDataset contains measurements of electric power comsumption (in kW) for 370 clients with a sampling rate of 15 minutes. For this case, if I want to add each clients with future covariates including temperature, wind speed, and humidity etc, How should I do.

Should I transform the multivariate time series (1 series with 370 components)to multiple time series (370 series with each having 1 component), and for each series to prepare a covariates time series with 3 components. It seems this way is straightforward.

Or just keep the multivariate time series unchanged, and prepare the covariates time series, If so, how should I prepare this kind of covariates time series to let the model know which three covariates belong to which client?

Is there any demo code for this kind of case. Thanks

dennisbader commented 4 months ago

Hi @ZhangAllen98, yes you should do it as you described here:

Should I transform the multivariate time series (1 series with 370 components)to multiple time series (370 series with each having 1 component), and for each series to prepare a covariates time series with 3 components. It seems this way is straightforward.

For this, simply create a list of single column time series from the electricity dataset:

from darts.datasets import ElectricityDataset
series = ElectricityDataset().load()
series = [series[col] for col in series.columns]

And then create a covariates TimeSeries for each of the series in series and pass them as a list of covariates TimeSeries of the same length (370) to the models.