1
$\begingroup$

I am new to neural networks (NN), so far I have been playing with the International Airline Passengers time-series dataset. To feed the NN, I transformed the data from:

ti

ti+1

ti+2

ti+3

...

to look like:

ti ti+1

ti+1 ti+2

ti+2 ti+3

...

and then feed the NN with the latter.

Now I would like to train neural networks on another dataset. I have three different features. The dataset looks like:

ti si ri

ti+1 si+1 ri+1

ti+2 si+2 ri+2

ti+3 si+3 ri+3

How can transform the dataset (as done previously) to feed it as input to the neural network?

Would it be something like:

ti si ri ti+1 si+1 ri+1

ti+1 si+1 ri+1 ti+2 si+2 ri+2

ti+2 si+2 ri+2 ti+3 si+3 ri+3

...

?

$\endgroup$
  • $\begingroup$ It's a univariate time series you are trying to forecast, you should change the title accordingly. Look for nnetar package if using R or Keras in Python :) $\endgroup$ – Tommaso Guerrini Feb 13 '17 at 21:26
  • $\begingroup$ What is the question? Is it how to code this (that would be off topic)? $\endgroup$ – Richard Hardy Feb 14 '17 at 7:45
  • $\begingroup$ The question is how do I feed the matrix as input to the neural network, not how to code the solution. The example I was working on had only one column, now I have three so I don't know how to preprocess the input matrix to train the NN. $\endgroup$ – Roxy Feb 14 '17 at 14:17
  • $\begingroup$ Your data indexes at the bottom are correct, assuming your are using a look_back of 1. So instead of input shape = (look_back,1) it would be (look_back,3) and your final dense layer should be: model.add(Dense(3)) so that the model is predicting 3 values. $\endgroup$ – photox Feb 14 '17 at 14:54
1
$\begingroup$

Say you have variables $X_1(t), X_2(t), X_3(t)$, measured at each time point $t$. If using a feedforward network, the input at each time step could be any array containing the values of the variables at the current and previous time steps (over some fixed interval). For example, the vector: $$[X_1(t), X_2(t), X_3(t), X_1(t-1), X_2(t-1), X_3(t-1), \dots]$$

Or, it could be a matrix: $$\left [ \begin{array}{ccc} X_1(t) & X_1(t-1) & \dots \\ X_2(t) & X_2(t-1) & \dots \\ X_3(t) & X_3(t-1) & \dots \\ \end{array} \right ]$$

The arrangement of the variables in the array doesn't matter if you're using a vanilla, fully connected network; the training procedure will learn the proper weights. But, the arrangement can matter if you're using a network architecture that makes assumptions about how neighboring values in the input are related to each other (e.g. convolutional nets).

If using a recurrent neural network (often used to process time series), the input at time $t$ would simply be the vector $[X_1(t), X_2(t), X_3(t)]$, and a new input would be fed in at each time step.

$\endgroup$
  • $\begingroup$ Thanks. What if using LSTM? $\endgroup$ – Roxy Feb 15 '17 at 13:45
  • $\begingroup$ LSTM is a type of recurrent network, so same as I mentioned at the bottom $\endgroup$ – user20160 Feb 15 '17 at 14:00

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.