I have a data matrix where each row is measurement in time and each column is a feature.
time, feature 1, feature 2, feature 3 0, a, b, c 1, d, e, f 2, g, h, i . . .
I would like to run some ML algorithms on this data (i also have with each row and associated label), regression, decision trees, but i want to add some time-sliding window features. That is for every measurement, say it has time i, i want to add the features of the measurement of time i-1 and i-2.
So the data matrix i want to end up with is:
time, feature 1, feature 2, feature 3, feature 1 time -1, feature 2 time -1, feature 3 time -3, feature 1 time -2, feature 2 time -2, feature 3 time -2 2, g, h, i, d, e, f, a, b, c 3, j, k, l, g, h, i, d, e, f 4, m, n, o, j, k, l, g, h, i . . .
Notice that row with time 0 and 1 is missing, since they do not have enough historical data to add.
I figured that this was a common task and perhaps there was some way to do this in sci kit learn. Is there? I saw some plugins for creating sliding window features in images or text , but for a regular data matrix.