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)

  • $\begingroup$ 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? $\endgroup$ – Sycorax Feb 17 at 18:37
  • $\begingroup$ I use variables like day, hour, month, year, etc, as input variables $\endgroup$ – Numbermind Feb 17 at 18:38
  • $\begingroup$ $y$ is a continuous variable $\endgroup$ – Numbermind Feb 17 at 18:40
  • $\begingroup$ 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. $\endgroup$ – Sycorax Feb 17 at 18:40
  • $\begingroup$ 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 $\endgroup$ – 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
from sklearn.ensemble import GradientBoostingClassifier
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))
  • $\begingroup$ 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? $\endgroup$ – Numbermind Feb 18 at 9:29
  • $\begingroup$ I'm just waiting for your confirmation to accept your answer. $\endgroup$ – Numbermind Feb 18 at 14:09
  • $\begingroup$ 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. $\endgroup$ – Sycorax Feb 18 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.