Deep Learning Toolkit for Price Forecasting Developer Guide


The Deep Learning Toolkit for Price Forecasting module tries to predict the next values of a dataset containing information about purchases of a given good. To obtain the best accuracy possible the dataset shall contain entries close in time between one another and each entry should provide information other than the timestamp about the price of the good at that time and the quantity purchased. The Deep Learning Toolkit should be trained first using already collected datasets to generate predictions, then, when operational, it keeps learning using the single entries provided when updates to prices are issued. This process is called online learning. If the initial dataset is small, initial results can be inaccurate because the LTSM neural network used is predicting the results using random weights which have not been optimised enough. The accuracy of the prediction should improve as additional data becomes available.


The two most interesting components from the development aspect in the Deep Learning Toolkit for Price Prediction architecture are the LSTM Neural Network and the REST API.

LSTM Neural Network Design

The Recurrent Neural Network used in this tool is made of two main building blocks:

  • Encoder: the encoder layer is mainly composed of a LSTM node.
  • Decoder: the decoder consists of a LSTM layer, followed by a fully connected one, which produces the output (through a linear activation).

Since the goal is to predict the future prices, the metrics used in order to evaluate the results are the MSE and the MAPE. In order to prevent the RNN to over-fit too much (despite collecting more data is the only way to make the model able to generalize properly), the following techniques have been applied:

  • Adding dropout;
  • Adding L2 regularization on the weights and activation parameters, L1 demonstrated to work poorly in this use case;
  • Early stopping, in order to prevent over-fitting on the training dataset when this brings no value on the validation set;
  • Adding more layers and making the network deeper had no effects on improving theresults. It means that the capacity of the abovementioned model is enough to describe the problem.


The users can interact with the DLT for price prediction through a set of HTTP based API shown in the table below.

Path HTTP verb Description
/good POST Creates a new good if it does not exist. It creates the correspondent network, untrained with the structure defined in the configuration files
/good GET Returns the list of all the goods created in the DLT
/goods/{id} GET Returns the details about the good {id}
/goods/{id} DELETE Deletes the good and the relative network and model
/goods/{id}/values POST Adds a new value to the good. Each time a new value is added, the network predicts the new value, then the network is trained with the input value
/goods/{id}/values GET Returns all the input values added through time.
/goods/{id}/predictions GET Returns all the predictions for a good in an array shaped form
/goods/{id}/predictions/last GET Returns the last prediction of the DLT (without adding a new value)