Closed tim-sadler closed 2 months ago
Hi @tim-sadler,
You can find an illustration of the difference between in the quickstart notebook.
Darts take care of slicing the series, so even if the covariates extend too far, the model won't have access to it during training. This is why the covariates_transformed
series is used directly in the example. You can slice the series if you want to convince yourself of that:
# will work
my_model.fit(train_transformed, future_covariates=covariates_transformed[:train_transformed.end_time()], verbose=True)
# won't work because covariates are too short
my_model.predict(n=1)
#will work because the covariates extend just enough into the future
ext_covariates_transformed = covariates_transformed[:train_transformed.end_time() + my_model.output_chunk_length * train_transformed.freq)
my_model.predict(n=1, future_covariates=ext_covariates_transformed)
# note that if n > output_chunk_length, the covariates will have to extend even further into the future
Since the model is trained on only one series (target and covariates), they are stored in the model and predict()
can be called directly without specifying them. It's still possible to pass another series/covariates to the TFTModel
as it is a GlobalModel
.
Let me know if anything is still unclear.
Hi @tim-sadler, I'd recommend reading our user guide on covariates from here and how the data is used for Sequential torch forecasting models from here.
TL;DR:
TimeSeries
, Darts model's remember that time series and covariates. So at prediction time, you don't have to supply the covariates again (this is to have a uniform API with our local models that can only be trained on a single series). If you trained the model on multiple series, you would have to pass the target and covariates series to predict()
.Edit: @madtoinou, you were quicker than me :D
I am struggling with the Air Passenger Example for Temporal Fusion Transformer (https://unit8co.github.io/darts/examples/13-TFT-examples.html) and the API documentation of the TFT documentation in general. (See copy and pasted code below).
Reading it, it is not clear, how
past_covariates
andfuture_covariates
behave inmodel.fit()
andmodel.predict()
.In the example above,
future_covariates
is set tocovariates_transformed
which is a transformed time series that stretches over both training and holdout period. Isn't true, that holdout data should never go into the training?In the holdout validation in the example,
future_covariates
is not used at all, even though this would be considered "future" since it is a validation against future holdout data.Could someone explain the behavior of
past_covariates
andfuture_covariates
to me in a framework of training vs. in-sample validation (e. g. using torch's val_loss) vs. out-of sample future predictions?Are there any examples you could refer me to that explain these concepts in detail?
Thank you very much for your help!
How the data is split:
Fit:
my_model.fit(train_transformed, future_covariates=covariates_transformed, verbose=True)
Holdout validation: