You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm struggling with problem of training and testing with TFTModel within past_covariates data only.
More detail I have a data includes 6 columns (1 target, and 5 features).
My model need to forecast target value based on information from 5 features.
My training code is below running without any error:
I got error in model.predict line with below infomation:
ValueError: For the given forecasting case, the provided past covariates at dataset index `0` do not extend far enough into the past. The past covariates must start at time step `2023-06-22`, whereas now they start at time step `2024-02-28`
So, I have 2 questions:
Is it possible to force the TFTModel to train with only past_covariates as the way I did in above?
If possible, how to correct my inference source code (also train source code if need) in order that the TFTModel can run train and inference with past_covariates only as I expect?
The text was updated successfully, but these errors were encountered:
Hi @nhthanh0809. Just quickly to verify some Darts vocabulary:
the target series is the one which we want to forecast
past covariates are other features (not the target variable itself) which are known (only) in the past (e.g. measurements, ...).
A) So if you ask whether it's possible to only use the past covariates (not the past of the target variable itself) to forecast the future of the target, then that is not possible with TFTModel.
Covariates-only forecasting is currently only supported by our RegressionModel (and all models deriving from it).
B) If you do want to use the past of the target variable and the past of the past covariates, then that is possible.
However, to be able to forecast the target over the time frame of your test_covariates, you must know and supply the target values and past covariates values over the last input_chunk_length=30 time steps before the start time of test_covariates.
If your test set begins right after the end of the validation set, then you would have to call predict as follows:
This generates a forecast over the entire test set using the target and covariates from before the test set start.
If your test set is longer than output_chunk_length=7, and you want to know how it would have performed if repeatedly predicting with n=7, then you should consider model.historical_forecasts().
from darts import concatenate
# concatenate val and test sets so we can start at the beginning of test
val_test_target = concatenate([val_target, test_target], axis=0)
val_test_covariates = concatenate([val_covariates, test_covariates], axis=0)
hfc = model.historical_forecasts(
n=7,
series=val_test_target,
past_covariates=val_test_covariates,
start=test_target.start_time(), # start at test start
retrain=False,
last_points_only=False, # return the full forecasts
stride=1, # optionally, you could also advance 7 steps after each prediction to get contiguous forecasts (in time)
)
B) If you do want to use the past of the target variable and the past of the past covariates, then that is possible.
How can i do like that, could you please correct my code for this purpose?
By the way, after training how can i run inference on train set and val set to check how model predict on that dataset?
I've tried your suggestion but it can not run with n=len(test_covariates)
Hi,
I'm struggling with problem of training and testing with TFTModel within past_covariates data only.
More detail I have a data includes 6 columns (1 target, and 5 features).
My model need to forecast target value based on information from 5 features.
My training code is below running without any error:
But when i load trained model then run inference with new data:
I got error in model.predict line with below infomation:
So, I have 2 questions:
The text was updated successfully, but these errors were encountered: