Do tree methods like gradient boosting predict all iterations at once?

If I'm using a tree method (e.g GBM) and I have a time series hourly data, and I predict my target variable $$y$$ for the next 48 hours, do my predictions were made all at once, or does the second day of prediction already use my first day of prediction as input?

For example, when I'm predicting $$y$$ at hour 2, does the model have in account the predicted value of $$y$$ at hour 1; and when I'm predicting $$y$$ at hour 3, does it have in account the value of $$y$$ at hour 2? and so on.. Or does the model predict all of the 48 values of $$y$$ without any connection between them (independently)?

I have all of the feature variables for the 48 hours, I only need to predict my target variable $$y$$. Basically, what I'm asking is if the method uses predictions to predict further ahead or does it predict all at once?

(The data does not have any lag features)

• Am I correct that you have $p$ features at each of $T$ time steps in an $T \times p$ matrix $X$? And you're using row $t$ in $X$ to predict $y_t$, a scalar? In other words, the only difference between the typical non-time-series GBT model and your model is that instead of exchangeable, atomic observations, your observations are indexed by time? – Sycorax Feb 17 at 18:37
• I use variables like day, hour, month, year, etc, as input variables – Numbermind Feb 17 at 18:38
• $y$ is a continuous variable – Numbermind Feb 17 at 18:40
• That doesn't answer my question. I'm trying to understand if there's anything about your model that makes it different from a model that's not a time series, or if the temporal nature of your task is purely incidental to what you're asking. – Sycorax Feb 17 at 18:40
• I don't think so. The data is a time series but I use my data as tabular data where the datetime column is the index and I have columns like day, year, hour, month, etc – Numbermind Feb 17 at 18:42

In the scenario you outline in the post and in comments, the predictions are atomic. Predictions for the feature vector of time $$t$$ don't depend on the feature vectors for any other times. This is because the time-series nature of the data is not reflected in any part of this model; the data are essentially a tabular.

All we need to do to verify this claim is show that predictions for tabular data don't change when you supply 1 or several vectors for prediction.

It's easy enough to verify this by writing a test:

from sklearn.datasets import make_hastie_10_2
import numpy as np

X, y = make_hastie_10_2(random_state=0)
X_train, X_test = X[:2000], X[2000:]
y_train, y_test = y[:2000], y[2000:]

clf = GradientBoostingClassifier(n_estimators=100, learning_rate=1.0, max_depth=1, random_state=0).fit(X_train, y_train)
foo = clf.predict_proba(X_test[10,:].reshape(1,-1))
bar = clf.predict_proba(X_test[0:11,:])
np.testing.assert_allclose(foo, bar[10,:].reshape(1,-1))

• Thanks for the answer! I've run your code and got no warning message, so I can assume that the predictions are made independently, right? – Numbermind Feb 18 at 9:29
• I'm just waiting for your confirmation to accept your answer. – Numbermind Feb 18 at 14:09
• Yes. The numpy testing function will raise an exception if the values aren’t sufficiently close. No exception implies that the values are sufficiently close. – Sycorax Feb 18 at 15:12