1
$\begingroup$

I have been trying to understand this sliding window technique but to no avail and really unsure as to how I would implement it.

My dataset: I have hourly values for the electric load for a year (over 8700 data points) - image below. I'm going to split the dataset into a training set (1 jan to 30 sept) and a test set (1 oct to 31 Dec).

Im going to use supervised learning techniques such as Regression trees and random forests (basically anything that is available to me in scikit learn), train them on the training set then make predictions on test set.

I understand that I need to use historical known values as input features to input into a model. As a result i created "Load_lagN".

Am I correct in saying that because I have created 10 lagged variables (Xt-1 to Xt-10) , this is the equivalent of using a sliding window of size 10?

How would I then just simply train the model on the training set and make predictions on the test set without using the sliding model?

With the sliding window model, does that assume only the past n values (10 in my case) are relevant?

If I have split my dataset into a training and test set, how does the regression tree become trained and then make predictions in the test set (I'll stick to one step ahead forecasting for now) whilst implementing this sliding window technique?

http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.TimeSeriesSplit.html#sklearn.model_selection.TimeSeriesSplit Ive come across this method - TimeSeriesSplit - is this what I need to use for the sliding window technique or is it only a cross validator?

My understanding of the sliding window method: As you can see in the image below, I use values of 10:00 to 19:00 to predict the value at 20:00, move the window so that this new value is now included, then predict the value for 21:00. This keeps happening until I have exhausted the training set. I then make predictions.

What are your thoughts?

First few values of dataset

$\endgroup$
  • 1
    $\begingroup$ You need to think about this dataset before making a model choice decision. First, the train/test set split is already wrong. Do you think the load shapes in spring, summer would predict fall and winter well? (also, one yr has 8760 hrs) $\endgroup$ – horaceT Mar 17 '18 at 17:50
  • $\begingroup$ i have considered this, I just wanted to see how it predicts. I'll optimise the training and tests sets later with respect which time period they cover $\endgroup$ – Robot_enthusiast Mar 17 '18 at 18:42
  • $\begingroup$ Also, time series models of the type that use lags are wrong choice for load forecast. Do you think hr 17 yesterday would predict hr 3 better? You need to understand your data bef asking questions. $\endgroup$ – horaceT Mar 17 '18 at 18:49
  • $\begingroup$ In the industry parlance, Hr17 is a peak hour where demand is highest (think Californians having their aircond at full blast), while Hr3 is in off-peak period where everybody is asleep. Depending on the region of the country you get your data from, Hr17 has little correlation with Hr3. $\endgroup$ – horaceT Mar 17 '18 at 18:57
  • $\begingroup$ why are lags the wrong choice? I've seen it mentioned in papers many times.. I hope to conduct an experiment to see how i can change the length of the window to see how RMSE changes - that way I'll know how many lags to use $\endgroup$ – Robot_enthusiast Mar 17 '18 at 19:38
4
$\begingroup$

Try this:

  1. Make the data stationary (remove trends and seasonality).
  2. Implement PACF analysis on the label data (For eg: Load) and find out the optimal lag value. Usually, you need to know how to interpret PACF plots.
  3. Apply the sliding window on the whole data (t+o, t-o) where o is the optimal lag value.
  4. Apply walk forward validation to train and test the models.

The way to escape sliding window is to use Recurrent Neural Networks but believe me, the method I suggested is worth it.

If you want the code: https://machinelearningmastery.com/time-series-forecasting-supervised-learning/

This can help too: Master Thesis research applicable to your question

$\endgroup$

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.