Repository navigation
Multi Layer Perceptron
Multi Layer Perceptron (MLP) has been used as the most naive approach in deep learning algorithms for time series forecasting. Daily or monthly univariate time series is fed into the input_output_generator function to prepare data to be used in deep learning model. "lag" parameter is used to split data as input and output of the model. This parameter defines number of previous time steps (lags) to be fed into the deep learning model. As we are interested in one-step ahead recursive forecasting, only the current time step will be used as the output of the model. As an example, input/output generation works as the following example:
A data frame (df) is introduced as df = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].
input_output_generator function splits the data into input and output as follows: lag=3 has been used for this example.

Number of input/output arrays will be generated by the aforementioned function to be used in training of the model. 75% of this data has been used for training and 25% for validating the model. Deep learning hyper parameters such as batch size, optimizer and learning rate and also the structure of the model (number of hidden layers and number of nodes in each hidden layer) have been adjusted for each time series data separately.
The model will be evaluated based on the metrics which is root mean squared error of validation set. In the following figure, model loss has been graphed versus number of epochs for train and validation sets. As can be observed 30 epochs are sufficient for training the model.

Finally, the trained model have been used to generate forecasts for the test set. One-step ahead recursive forecasting has been used in this example.
