## 3 Materials and Methods
### Proposed Algorithm for Setting up the Parameters of the Predictive Analytical Module  
The proposed analytical module has implemented its algorithm for the automatic setting of NAR NN model parameters. The authorized user determines the initial parameters such as--the initial size of the input layer, the critical size of the input layer and other critical parameters, minimum number of training data, the minimum number of prediction steps, size of the evaluated sample, number of hidden layers and number of neurons in them. This adaptation algorithm starts by checking the number of stored data (samples) in the DB. If the number of samples in the database is equal to or greater than defined in the _minTrainingDataAmount_ parameter, it is possible to call the function for creating training data. On this data, the newly created NAR model is trained and after training, an estimate of the number of steps to the future is calculated, which is defined in the _stepsAheadParam_ parameter. Our proposed algorithm can be seen in the Figure 8 below. The algorithm is constantly checking if there is a new sample in the database. If there is a new sample, the input layer of the model is filled by help of a SQL query command. When the input layer of the model is filled, there is possible to estimate a prediction on a time which is defined by the parameter _stepsAheadParam_ and the sampling interval. After the prediction is estimated the result is stored back to the PostgreSQL DB to a table, where the results of the predictions should be stored. If there is more or equal samples than defined in the parameter _evalSize_, it is possible to finally calculate the accuracy metrics. If the calculated accuracy is sufficient, the algorithm waits for new samples so the prediction can be calculated again and this process can be repeated again. If the accuracy parameter is not sufficient it is necessary to modify the model parameters such as _inputLayerSize_ and _stepsAheadParam_. In addition, the new training is made on the expanded data set. This data set is obtained directly from PostgreSQL DB. When the new training data set is created, the parameters of the NAR models will be modified also. In the initial process, there needs to be set up an initial size of the input layer and the critical size of the input layer. This input layer size is affecting the size of the training dataset, which can affect the performance of the analytical HW during the training and thus the algorithm will modify _stepsAheadParam_, if the modification of the  
Figure 8: Proposed algorithm for automatic model parameter configuration. input layer size will not improve the accuracy of the model. The algorithm uses predefined constant values for decrementing the _stepsAheadParam_ and incrementing the parameter called _inputLayerSize_. Predicted and actual true values are stored in a database so that a degree of accuracy can be calculated between these estimated and collected data. It is possible to use several statistical parameters such as root mean squared error RMSE [28], mean absolute percentage error MAPE [28], or correlation coefficient R [29]. The formulas for each statistical metric are in the equations given below. \[\text{RMSE}=\sqrt{\frac{\sum_{i=1}^{enSize}(x_{i}-y_{i})^{2}}{evalSize}}\, \tag{3}\]  
\[\text{MAPE}=\frac{100}{evalSize}\sum_{i=1}^{enValueSize}\left|\frac{x_{i}-y_{i} }{x_{i}}\right|\, \tag{4}\]  
\[\text{R}=\frac{1}{evalSize-1}\sum_{i=1}^{evalSize}\left(\frac{x_{i}-\overline {x}_{i}}{s_{x}}\right)\left(\frac{y_{i}-\overline{y_{i}}}{s_{y}}\right)\, \tag{5}\]  
where variable \(x\) represents the real values measured by sensors, \(y\) represents the predicted values by NAR neural network model, \(s_{x}\) and \(s_{y}\) are the sample standard deviation for the real measured values and the predicted variables. It is necessary to have a certain number of samples of the predicted variable in the DB. This quantity is defined in the _evalSize_ parameter.