I have an hourly time series data like this:
df.head()
y v1 v2 v3 v4 v5 v6
20 1 29 3 4 0 2020
23 1 24 2 3 1 2020
29 0 17 5 6 2 2020
35 0 15 5 6 3 2020
I'm using XGBoost or GBM to predict $y$ for the next day (24 hours). Since methods like GBM or XGBoost don't take into account trends or patterns of time series, I added variables like year, hour, month, etc.. to the data. Since it doesn't take the last value into account I also created a lag variable ($x$) for $y$:
df.head()
y v1 v2 v3 v4 v5 v6 x
20 1 29 3 4 0 2020
23 1 24 2 3 1 2020 20
29 0 17 5 6 2 2020 23
35 0 15 5 6 3 2020 29
Since I'm only predicting one variable ($y$) by using as input the other variables, how will my second, third, etc.. hour have in account the lag value? My pipeline is something similar to this:
import numpy as np
df_train = df
X1=df_train[['v1','v2','v3','v4','v5','v6','x']
y1=df_train['y']
from sklearn.model_selection import train_test_split
X_train, y_train =X1, y1
X_test=df_test[['v1','v2','v3','v4','v5','v6','x']
regressor=XGBRegressor()
regressor.fit(X_train,y_train)
regressor.predict(X_test)
However, I cannot give $x$ as input to predict the next 24 hours because I don't have values of x for the next 24 hours because they always depend on the last day. Is it possible for the model to predict, for example, hour 5 using the value $x$ of the predicted $y$ value at hour 4?
Edit: And if it is not possible to use predictions at time $t$ to be a lag feature for the prediction at time $t+1$, how can I overcome this issue? Can I simply predict both $x$ and $y$?