# Machine Learning Algorithm for Delay Prediction in IoT and Tactile Internet
## 3 Machine Learning for Time Series Prediction
### K-Step-Ahead Prediction  
The primary purpose of modeling is to predict the subsequent output values using the previous and current values of the estimation unit. This unit was first determined using test information, matching several models to the dataset based on historical values, from which the optimal one was selected. Then, a new dataset was used in the unit, and the forecasting performances were compared. It was analyzed how the model can adapt to the output pattern. In this study, many prediction models were compared, k-step-ahead prediction (one-step,..., k-steps), using four different training algorithms--Trainlm, Traincf, Trainbr, and Trainpr--to investigate which is the optimal performance generated based on these algorithms. In general, time series forecasting determines the prediction of the observed data for the following time step. This is known as one-step prediction, open-loop, or SSP, as only a single time step can be predicted. One-step (\(n+1\)) prediction is performed by passing the present and previous data points (\(n\), \(n-1\),..., \(n-k\)). In this method, the current model is always replaced by updated input values. That is, the model is permanently changed depending on the adjusted parameter values. For multi-step predictions, the same model is used repeatedly to predict all output values. In the simplest case, one-step prediction models have the following form:  
\[y(n+1)=f(y(n),y(n-1),u(n),u(n-1)\ldots.(n-k)) \tag{3}\]  
where \(y(n+1)\) is the predicted output; \(y(n)\)_and_\(u(n)\) are the observation of the target and exogenous inputs, respectively; \(n\) is the time step; \(k\) is the number of inputs (\(k\)-step prediction); and \(f(. )\) is the prediction function learned by the model. In multi-step or \(k\)-step prediction, the same model is used repeatedly to predict all output values. The following equation can describe the prediction model in this method:  
\[y(n+k)=f(y(n),y(n-1)\ldots.y(n-k_{y})\;u(n),x(n-1)\ldots,u(n-k_{x}) \tag{4}\]  
where \(y(n+k)\) is the predicted output, \(k_{x}\) is the number of input delays (unit delay), and \(k_{y}\) is the number of output delays. The multi-step-ahead method predicts the following values of a historical time sequence step by step. First, \(u(n+1)\) is expected based on the previous x-values, \(u(n+1-x)\)..., \(u(n-1)\), then \(u(n+2)\) is predicted depending on the past x-values that contain the expected value for \(u(n+1)\). The process repeats until the final value, \(u(n+k)\), is measured. There are some tasks involving time series where multiple time steps must also be predicted. In contrast to SSP, these are called MSP or multi-step time series prediction problems. MSP is an exciting forecasting method that uses an autoregressive model to form  
Figure 2: NARX neural network architecture [22; 23; 30]. a closed loop in the forecast. It is a forecasting method that predicts potential measures in the historical time series based on past values. The multi-step forecasting technique applies a stepwise forecasting model that uses the expected measures in the actual period to determine their values in the following step. Many temporal series problems involve predicting successive potential values, using only the previous values, such as multi-step time sequence prediction, which predicts the historical time sequence for many problems, such as wireless network traffic, energy consumed, etc. Aware of the series of subsequent values, we can extract fascinating features of the historical time sequence, such as expected bandwidth, delay, throughput, energy consumption, uncertainties, attack time, and higher or lower measures with unusual frequency. In particular, predicting the historical time sequence in multiple steps allows us to predict the cropping season for next year, the delay in a wireless network for the next hour, low and high weather temperatures for the coming months, etc.