Hi! I have a multiple time-series forecasting task...
# mlforecast
t
Hi! I have a multiple time-series forecasting task and I want to use lags of all available time series for predicting each of them. That is, for time series A,B,C I want to use A_lag1, B_lag1, C_lag1 for predticting all of A,B,C... I have a hard time getting the lags to show up without duplicating one of the features as 'y' column... I thought about swapping values between columns depending on the unique_id, but it seems like a cumbersome way to do it. Is there a way to use features from other time series / other unique_id for predicting another series?
j
Hey. This isn't possible, each serie builds its features individually. skforecast does support this though, so that may be a better fit for your use case (docs)
t
Hi, thanks for the response... I found this exact doc page before and I think I managed to replicate their training setup for the dependent multivariate scenario in mlforecast using lag transforms on all the targets as exogenous vars, join them by ds after preprocessing and avoiding using 'y' lags... i might share the code later if i achieve some sensible results
j
The problem will be updating them, since at the predict step you have to recompute those features with the predictions, unless your horizon is shorter than the lags you're using and you're able to build the future exogenous upfront
t
what about restricting the scenario to model per step using max horizon? would that solve the issue?
j
I guess you could do that and provide the future values (last values? of each serie) as future exogenous
t
i one-hot encode the unique_id and all the last values for all the targets are included as exogenous, i believe the model should learn to see which columns are relevant
@José Morales sorry to bother but i'm not sure i understood what you meant by your last message correctly, can you elaborate please?
j
The problem is that the model will require the lag1 of each serie (or the series that you're using as features), which at the predict step is the last value of each serie, so you can do something like
last = train.groupby('unique_id').tail(1)
(assuming train is sorted by date), then repeat that
h
times, adjust the dates and provide that as
X_df
to predict. But to be honest then mlforecast isn't really doing anything, you could do that with just sklearn or other framework
t
@José Morales hmm, but using the max_horizon argument creates multiple targets y_1, y_2, ... y_h per row and we should be able to predict all of them at once, no?
j
you can use
MLForecast.preprocess
to get the targets and take it from there
1