Monday, 22 May 2023

Multi covariate time series forecast using Darts

I am trying to use the tutorial here, where we have two covariates to predict the target.

The tutorial uses .stack() to add two covariates together. It is not clear to me how to use this function to add more than two covariates to the model.

I tried the following code:

from darts.models import BlockRNNModel


my_covariate = (tg.sine_timeseries(length=LENGTH, 
                                value_frequency=(1/14), 
                                freq='D', 
                                column_name='my_covariate')
             + 0.4 * tg.gaussian_timeseries(length=LENGTH, freq='D'))


brnn_melting_and_rain = BlockRNNModel(input_chunk_length=30, 
                                      output_chunk_length=10, 
                                      n_rnn_layers=2)

brnn_melting_and_rain.fit(flow_train, 
                          # past_covariates=melting.stack(rainfalls).stack(rainfalls), 
                          past_covariates=[melting,rainfalls,my_covariate],
                          epochs=10, 
                          verbose=True)

eval_model(brnn_melting_and_rain, 
           past_covariates=melting.stack(rainfalls))

But I got the following error:

ValueError: The provided sequence of target series must have the same length as the provided sequence of covariate series.

I tried reading the documentation of DARTS, but there is no clear direction on how to use past_covariates, in specific, what is the data type I should pass here and if there are any other requirements.



from Multi covariate time series forecast using Darts

No comments:

Post a Comment