how to split a large timeseries into multiple samples with scikit learn?

Viewed 34

So I have a series of returns, lets say 1000 observations long. With each timestep I also have 10 features id like to train as predictors of said returns. So my total data set shape looks like: (1000, 11) i.e (1000 observations, each with 1 closing price and 10 features.)

My challenge is I need to turn this into the following format to train any kind of recurrent NN: (samples, timestep, features), where each sample(s) is a portion of the original 1000 observations.

Following my example if we take 5 samples of 1000 observations we get a shape of (5, 200, 11) that I need to obtain to train my model. 5 samples, 200 obs each, with 11 corresponding features.

What is the easiest way to get from (1000, 11) to (5, 200, 11) with the final product being dtype np.array?

0 Answers
Related